我正在尝试配置 NHibernate
包 id="NHibernate"version="4.0.0.4000"targetFramework="net451"
和 fluent 包 id="FluentNHibernate"version="2.0.1.0"targetFramework="net451"
。以下代码:
var sessionFactory = Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory)
.Mappings(m =>
{
m.FluentMappings
.AddFromAssemblyOf<ExampleSagaMap>();
)
.ExposeConfiguration(cfg =>
{
chemaExport = new SchemaExport(cfg);
})
.BuildSessionFactory();
map 代码:
public ExampleSagaMap()
{
Not.LazyLoad();
Id(x => x.CorrelationId).GeneratedBy.Assigned();
Map(x => x.CurrentState)
.Access.ReadOnlyPropertyThroughCamelCaseField(Prefix.Underscore)
.CustomType<StateMachineUserType>();
Map(x => x.MessagesReceived);
Map(x => x.MessagesSent);
}
错误:
An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
Inner error: {"Field not found: 'NHibernate.NHibernateUtil.String'."}
有人可以帮忙吗? 谢谢
最佳答案
在我的例子中,我收到此错误是因为我使用引用 NHibernateUtil.String.SqlType
的 IUserType
实现了自定义枚举类型。
解决方案是改用新的 SqlTypeFactory
。
/* Used by NHibernate to cast between string and type-safe-enum */
public class MyCustomEnumType : IUserType
{
...
public SqlType[] SqlTypes
{
get {
return new[] {
// not working for NHibernate 4.1
//NHibernateUtil.String.SqlType
SqlTypeFactory.GetString(200)
};
}
}
...
}
关于c# - 找不到字段 : 'NHibernate.NHibernateUtil.String' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32219619/