2015-08-26 4 views
2

Я пытаюсь настроить NHibernate пакет id="NHibernate" version="4.0.0.4000" targetFramework="net451" с плавным пакетом id="FluentNHibernate" version="2.0.1.0" targetFramework="net451". Следующий код:Не найдено: 'NHibernate.NHibernateUtil.String'

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); 
} 

Ошибка:

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'."}

Может кто-то пожалуйста, помогите.

ответ

0

В моем случае я получал эту ошибку, потому что у меня был пользовательский тип перечисления с использованием 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) 
      }; 
     } 
    }   

    ... 
}