时间:2021-07-01 10:21:17 帮助过:20人阅读
实体:
using System; using System.Text; using System.Collections.Generic; namespace Sample.CustomerService.Domain { public class TTesttype { public virtual string Id { get; set; } public virtual int? Type2 { get; set; } public virtual string Type3 { get; set; } public virtual string Type4 { get; set; } public virtual byte[] Type5 { get; set; } public virtual int? Type6 { get; set; } public virtual int? Type7 { get; set; } public virtual string Type8 { get; set; } public virtual DateTime? Type9 { get; set; } public virtual DateTime? Type10 { get; set; } public virtual string Type11 { get; set; } public virtual string Type12 { get; set; } public virtual string Type13 { get; set; } public virtual float? Type14 { get; set; } public virtual int? Type15 { get; set; } public virtual string Type16 { get; set; } public virtual string Type17 { get; set; } public virtual string Type18 { get; set; } public virtual int? Type19 { get; set; } public virtual string Type20 { get; set; } public virtual string Type21 { get; set; } public virtual string Type22 { get; set; } public virtual string Type23 { get; set; } public virtual int? Type24 { get; set; } public virtual string Type25 { get; set; } public virtual DateTime? Type26 { get; set; } public virtual DateTime Type27 { get; set; } public virtual string Type28 { get; set; } public virtual int? Type29 { get; set; } public virtual string Type30 { get; set; } public virtual string Type31 { get; set; } public virtual string Type32 { get; set; } public virtual string Type33 { get; set; } } }
第二种映射是通过xml映射文件来做的。
映射文件:
<?xml version="1.0" encoding="utf-8"?> <hibernate-mapping assembly="Sample.CustomerService" namespace="Sample.CustomerService.Domain" xmlns="urn:nhibernate-mapping-2.2"> <class name="TTesttype" table="t_testtype" lazy="true" > <id name="Id" column="Id" /> <property name="Type2"> <column name="type2" sql-type="bigint(20)" not-null="false" /> </property> <property name="Type3"> <column name="type3" sql-type="binary(1)" not-null="false" /> </property> <property name="Type4"> <column name="type4" sql-type="bit(1)" not-null="false" /> </property> <property name="Type5"> <column name="type5" sql-type="blob" not-null="false" /> </property> <property name="Type6"> <column name="type6" sql-type="tinyint(1)" not-null="false" /> </property> <property name="Type7"> <column name="type7" sql-type="tinyint(1)" not-null="false" /> </property> <property name="Type8"> <column name="type8" sql-type="char(1)" not-null="false" /> </property> <property name="Type9"> <column name="type9" sql-type="date" not-null="false" /> </property> <property name="Type10"> <column name="type10" sql-type="datetime" not-null="false" /> </property> <property name="Type11"> <column name="type11" sql-type="decimal(10,0)" not-null="false" /> </property> <property name="Type12"> <column name="type12" sql-type="double" not-null="false" /> </property> <property name="Type13"> <column name="type13" sql-type="enum(‘A‘,‘B‘,‘C‘)" not-null="false" /> </property> <property name="Type14"> <column name="type14" sql-type="float" not-null="false" /> </property> <property name="Type15"> <column name="type15" sql-type="int(11)" not-null="false" /> </property> <property name="Type16"> <column name="type16" sql-type="longblob" not-null="false" /> </property> <property name="Type17"> <column name="type17" sql-type="longtext" not-null="false" /> </property> <property name="Type18"> <column name="type18" sql-type="mediumblob" not-null="false" /> </property> <property name="Type19"> <column name="type19" sql-type="mediumint(9)" not-null="false" /> </property> <property name="Type20"> <column name="type20" sql-type="mediumtext" not-null="false" /> </property> <property name="Type21"> <column name="type21" sql-type="decimal(10,0)" not-null="false" /> </property> <property name="Type22"> <column name="type22" sql-type="double" not-null="false" /> </property> <property name="Type23"> <column name="type23" sql-type="set(‘X‘,‘Y‘,‘Z‘)" not-null="false" /> </property> <property name="Type24"> <column name="type24" sql-type="smallint(6)" not-null="false" /> </property> <property name="Type25"> <column name="type25" sql-type="text" not-null="false" /> </property> <property name="Type26"> <column name="type26" sql-type="time" not-null="false" /> </property> <property name="Type27"> <column name="type27" sql-type="timestamp" not-null="true" /> </property> <property name="Type28"> <column name="type28" sql-type="tinyblob" not-null="false" /> </property> <property name="Type29"> <column name="type29" sql-type="tinyint(4)" not-null="false" /> </property> <property name="Type30"> <column name="type30" sql-type="tinytext" not-null="false" /> </property> <property name="Type31"> <column name="type31" sql-type="varbinary(1024)" not-null="false" /> </property> <property name="Type32"> <column name="type32" sql-type="varchar(8)" not-null="false" /> </property> <property name="Type33"> <column name="type33" sql-type="year(4)" not-null="false" /> </property> </class> </hibernate-mapping>
没什么内容,只是记录一下,因为在做映射的时候,都不知道怎么匹配类型,这里可以做个参考。
Nhibernate + MySQL 类型映射
标签:customers str pre time src date com main map