Convertir un IList en un Array
.Net January 28th, 2010
SQL Server’s nvarchar(max) on Castle ActiveRecord
.Net, SQL, Software May 6th, 2009
I’m using the new SQL Server 2005’s data type nvarchar(max) on a .Net project (ntext has been deprecated in this version) in conjuction with Castle ActiveRecord. For a complete integration (including schema creation), ActiveRecord property should looks like this:
[Property("description", ColumnType = "StringClob", SqlType = "nvarchar(MAX)")]
ColumnType = “StringClob” avoids text to be truncated if it gets too long. SqlType = “nvarchar(MAX)” forces the field to be created as that data type, otherwise, it will be created as nvarchar(255).
A more detailed explanation can be found here and here.
Tags: ActiveRecord, Castle, Hibernate, NHibernate, nvarchar, nvarchar(max), SQL Server
Convertir un ArrayList a string[]
.Net November 30th, 2008
Diferencia entre ICollection e IList en C#
.Net October 30th, 2008
Los elementos dentro de un ICollection (para ser más exactos, los elementos dentro de una clase que implemente una interfaz ICollection) no tienen un orden específico. En un momento pueden estar ordenados de una manera, y en otro, sin alguna razón aparente, ordenados de otra forma.
En cambio, los elementos de un IList si tienen un orden establecido y relevante, como un arreglo. Esto permite agregar elementos en una ubicación específica. Además, los elementos van a permanecer en la posición asignada hasta que decidamos moverlos.
Además de estas dos interfaces, existe también IDictionary, que exitiende a ICollection. Este permite almacenar parejas de elementos (clave, valor), similar a como lo hace un diccionario de palabras (cada palabra tiene un significado). Al igual que en el ICollection, estos elementos no tienen un orden específico.
Tags: .Net, C#, ICollection, IDictionary, IList
Obtener el MimeType de un archivo desde C#
.Net October 24th, 2008
No he encontrado una manera directa de hacerlo, pero encontré esta función que busca la extensión del archivo en el registro de windows y si está registrada, obtiene su tipo mime.
1 2 3 4 5 6 7 8 9 | private string getMimeType(string fileName) { string mimeType = "application/unknown"; string ext = System.IO.Path.GetExtension(fileName).ToLower(); Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext); if (regKey != null && regKey.GetValue("Content Type") != null) mimeType = regKey.GetValue("Content Type").ToString(); return mimeType; } |
Aún no la pruebo, pero según loque leí, funciona bien. Los post originales están acá y acá.
About











