1
我配置了Fluent NHibernate来映射项目中的实体。我的实体没有公开属性(除了它们的Id),它们的所有数据都存储在私有字段中。FluentNHibernate中的私有字段
使用:
public override bool ShouldMap(Member member)
{
return member.Name == "Id" || (member.IsPrivate && member.IsField);
}
它成功地找到我的领域,但后来我预计数据库列被称为像_emailAddress事情。
如何将_emailAddress映射到名为EmailAddress的列?我的SessionFactory初始化如下所示:
Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey("AppConnection")))
.Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<User>(new NHibMappingConfiguration())
.Conventions.Add(DefaultAccess.CamelCaseField(CamelCasePrefix.Underscore))))
.CurrentSessionContext("web")
.ExposeConfiguration(BuildSchema)
.BuildSessionFactory();
明显使用默认访问约定。
谢谢, 马特
感谢这里的第一个选项为我工作。似乎应该有一个更简单的方法,但是这样做的窍门谢谢! – mattcole 2011-05-09 20:27:10