我是NHibernate的新手,并尝试使用Fluent进行映射.我的实体类名称与必须映射到的数据库表名称不同.我使用来源于映射类ClassMap<>
,但我不能指定表名:属性TableName
从ClassMap
是只读的.
谢谢你的帮助.
请Table("table_name")
改用.
它有效吗?
public class UserAccountMap : ClassMap{ public UserAccountMap() { Table("User"); Id(x => x.UserID, "UserID").GeneratedBy.Identity(); Map(x => x.FirstName, "FirstName").Length(50) .Not.Nullable(); Map(x => x.LastName, "LastName").Length(50) .Not.Nullable(); } }
上面的例子引导我朝着正确的方向前进.这对我有用.我的班级名称是"Party",我的名字是"prty.Party".
public class PartyMap : ClassMap{ public PartyMap() { Table("prty.Party"); Id(x => x.PartyID); Map(x => x.PartyTypeLID); Map(x => x.OrganizationTypeLID); Map(x => x.PreferredContactMethodLID); Map(x => x.PrimaryLanguageLID); Map(x => x.PartyVID); Map(x => x.BeginDate); Map(x => x.EndDate); Map(x => x.RowDescriptor); Map(x => x.RowModifiedDate); Map(x => x.RowModifiedBy); Map(x => x.RowCreatedDate); Map(x => x.RowCreatedBy); } }