gpt4 book ai didi

c# - 找不到字段 : 'NHibernate.NHibernateUtil.String'

转载 作者:行者123 更新时间:2023-11-30 18:23:28 24 4
gpt4 key购买 nike

我正在尝试配置 NHibernateid="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.SqlTypeIUserType 实现了自定义枚举类型。

解决方案是改用新的 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com