字段未找到:'
本文关键字:字段 | 更新日期: 2023-09-27 18:09:55
我正在尝试配置NHibernate
包id="NHibernate" version="4.0.0.4000" targetFramework="net451"
与流畅包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();
地图代码:
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);
}
错误:
创建时使用了无效或不完整的配置SessionFactory。检查PotentialReasons集合和InnerException查看详细信息。
内部错误:{"字段未找到:'NHibernate.NHibernateUtil.String'."}
有人能帮帮我吗?由于
在我的情况下,我得到这个错误,因为我已经实现了一个自定义枚举类型使用IUserType
引用NHibernateUtil.String.SqlType
。
解决方案是使用新的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)
};
}
}
...
}