nhibernate映射类型

NHibernate Type.NET TypeDatabase TypeRemarks
AnsiCharSystem.CharDbType.AnsiStringFixedLength - 1 char
BooleanSystem.BooleanDbType.BooleanDefault when no type attribute specified.
ByteSystem.ByteDbType.ByteDefault when no type attribute specified.
CharSystem.CharDbType.StringFixedLength - 1 charDefault when no type attribute specified.
DateTimeSystem.DateTimeDbType.DateTime - ignores the millisecondsDefault when no type attribute specified.
LocalDateTimeSystem.DateTimeDbType.DateTime - ignores the millisecondsEnsures the DateTimeKind is set to DateTimeKind.Local
UtcDateTimeSystem.DateTimeDbType.DateTime - ignores the millisecondsEnsures the DateTimeKind is set to DateTimeKind.Utc
DecimalSystem.DecimalDbType.DecimalDefault when no type attribute specified.
DoubleSystem.DoubleDbType.DoubleDefault when no type attribute specified.
GuidSystem.GuidDbType.GuidDefault when no type attribute specified.
Int16System.Int16DbType.Int16Default when no type attribute specified.
Int32System.Int32DbType.Int32Default when no type attribute specified.
Int64System.Int64DbType.Int64Default when no type attribute specified.
PersistentEnumA System.EnumThe DbType for the underlying value.Do not specify type="PersistentEnum" in the mapping. Instead specify the Assembly Qualified Name of the Enum or let NHibernate use Reflection to "guess" the Type. The UnderlyingType of the Enum is used to determine the correct DbType.
SingleSystem.SingleDbType.SingleDefault when no type attribute specified.
TicksSystem.DateTimeDbType.Int64type="Ticks" must be specified.
TimeSpanSystem.TimeSpanDbType.Int64Default when no type attribute specified.
TimestampSystem.DateTimeDbType.DateTime - as specific as database supports.type="Timestamp" must be specified.
TrueFalseSystem.BooleanDbType.AnsiStringFixedLength- 1 char either 'T' or 'F'type="TrueFalse" must be specified.
YesNoSystem.BooleanDbType.AnsiStringFixedLength- 1 char either 'Y' or 'N'type="YesNo" must be specified.

System.Object映射类型

NHibernate Type.NET TypeDatabase TypeRemarks
AnsiStringSystem.StringDbType.AnsiStringtype="AnsiString" must be specified.
CultureInfoSystem.Globalization.CultureInfoDbType.String - 5 chars for cultureDefault when no type attribute specified.
BinarySystem.Byte[]DbType.BinaryDefault when no type attribute specified.
TypeSystem.TypeDbType.String holding Assembly Qualified Name.Default when no type attribute specified.
StringSystem.StringDbType.StringDefault when no type attribute specified.

LargeOjbect映射类型

NHibernate Type.NET TypeDatabase TypeRemarks
StringClobSystem.StringDbType.Stringtype="StringClob" must be specified. Entire field is read into memory.
BinaryBlobSystem.Byte[]DbType.Binarytype="BinaryBlob" must be specified. Entire field is read into memory.
SerializableAny System.Object that is marked with SerializableAttribute.DbType.Binarytype="Serializable" should be specified. This is the fallback type if no NHibernate Type can be found for the Property.

本文由 hcb 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处。

还不快抢沙发

添加新评论