NHibernate mapping types are specific types that describe data model in ORM. Each mapping type is associated to some .NET and DB type. NHibernate types execute bridge functionality between DB types and .NET types to map them.
There are two main type groups: entities and value types. Value types represent simple data types as numeric values, character values, etc. Entity types are a kind of composite type that consists of simple value types. Value types are used for mapping of DB table fields, whereas entities are used to describe DB tables. There are a lot of built-in mapping types in NHibernate. Some of them can be mapped to few .NET types, and others have strict typing and do not support type conversion. NHibernate also has a possibility to create and use custom mapping types that extends the possibility of mapping types using.
Entity Developer for NHibernate provides the possibility to specify NHibernate property types, complex types and enum types.
Below is the description of NHibernate types available in Entity Developer for NHibernate.
NHibernate Type |
.NET Type |
Database Type |
AnsiChar |
System.Char |
DbType.AnsiStringFixedLength - 1 char |
Boolean |
System.Boolean |
DbType.Boolean |
Byte |
System.Byte |
DbType.Byte |
Char |
System.Char |
DbType.StringFixedLength - 1 char |
Currency |
System.Decimal |
DbType.Decimal |
Date |
System.DateTime |
DbType.Date |
DateTime |
System.DateTime |
DbType.DateTime - ignores the milliseconds |
DateTime2 |
System.DateTime |
DbType.DateTime2 |
DateTimeOffset |
System.DateTimeOffset |
DbType.DateTimeOffset |
DbTimeStamp |
System.DateTime |
DbType.Date |
Decimal |
System.Decimal |
DbType.Decimal |
Double |
System.Double |
DbType.Double |
Guid |
System.Guid |
DbType.Guid |
Int16 |
System.Int16 |
DbType.Int16 |
Int32 |
System.Int32 |
DbType.Int32 |
Int64 |
System.Int64 |
DbType.Int64 |
LocalDateTime |
System.DateTime |
DbType.DateTime |
Object |
System.Object |
DbType.Object |
SByte |
System.SByte |
DbType.SByte |
Single |
System.Single |
DbType.Single |
Ticks |
System.DateTime |
DbType.Int64 |
Time |
System.DateTime |
DbType.Time |
TimeAsTimeSpan |
System.TimeSpan |
DbType.Time |
TimeSpan |
System.TimeSpan |
DbType.Int64 |
Timestamp |
System.DateTime |
DbType.DateTime - as specific as database supports. |
TrueFalse |
System.Boolean |
DbType.AnsiStringFixedLength - 1 char either 'T' or 'F' |
UInt16 |
System.UInt16 |
DbType.UInt16 |
UInt32 |
System.UInt32 |
DbType.UInt32 |
UInt64 |
System.UInt64 |
DbType.UInt64 |
UtcDateTime |
System.DateTime |
DbType.DateTime |
YesNo |
System.Boolean |
DbType.AnsiStringFixedLength - 1 char either 'Y' or 'N' |
NHibernate Type |
.NET Type |
Database Type |
AnsiString |
System.String |
DbType.AnsiString |
Binary |
System.Byte[] |
DbType.Binary |
CultureInfo |
System.Globalization.CultureInfo |
DbType.String - 5 chars for culture |
String |
System.String |
DbType.String |
Type |
System.Type |
DbType.String holding Assembly Qualified Name. |
NHibernate Type |
.NET Type |
Database Type |
BinaryBlob |
System.Byte[] |
DbType.Binary |
Serializable |
Any System.Object that is marked with SerializableAttribute. |
DbType.Binary |
StringClob |
System.String |
DbType.String |
The type of a property is specified in the Type drop-down list in the Property Editor dialog box. Besides basic NHibernate types, as a Type of a property it is also possible to select ComplexType or EnumType objects declared in your model. It is also possible to assign any class name of a custom type as a Type of a property. If you use a certain custom type very often, it may be useful to define a shorter name for it. You can do this by defining a TypeDef in the model for your custom type. Note that you have to specify full assembly-qualified names for all except basic NHibernate types.