2
모든 bool 특성에 적용되는 규칙을 작성하려고합니다. Fluent NHibernate bool 용 사용자 정의 유형 규칙
이 클래스를 감안할 때 :이 수행하는 규칙을 가지고 싶습니다public class ProductMap : ClassMap<Product>
{
public ProductMap()
{
Map(x => x.Name);
Map(x => x.IsActive).CustomType<YesNoType>();
}
}
:
public class Product
{
public string Name { get; private set; }
public bool IsActive { get; private set; }
public Product(string name)
{
Name = name;
}
}
내가 같은 매핑을 가지고있다. 지금까지 내가 가진 :
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(c => c.FromConnectionStringWithKey("dev"))
.AdoNetBatchSize(256)
.UseOuterJoin()
.QuerySubstitutions("true 1, false 0, yes 'Y', no 'N'"))
.CurrentSessionContext<ThreadStaticSessionContext>()
.Cache(cache => cache.ProviderClass<HashtableCacheProvider>())
.ProxyFactoryFactory<ProxyFactoryFactory>()
.Mappings(m => m.FluentMappings.AddFromAssembly(mappingAssembly)
.Conventions.Add(new ForeignKeyNameConvention(),
new ForeignKeyContstraintNameConvention(),
new TableNameConvention(),
new YesNoTypeConvention(),
new IdConvention()))
.ExposeConfiguration(c => c.SetProperty("generate_statistics", "true"))
.BuildSessionFactory();
그러나 규칙이 적용되지 않고있다 :
public class YesNoTypeConvention : IPropertyConvention, IPropertyConventionAcceptance
{
public void Apply(IPropertyInstance instance)
{
instance.CustomType<YesNoType>();
}
public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
{
criteria.Expect(x => x.Property.DeclaringType == typeof(bool));
}
}
나는 등의 규칙을 추가하고있다. 문제는 Apply 메소드의 Expect 조건이라고 생각합니다. DeclaringType 및 PropertyType 같은 다른 속성 유형을 시도했습니다.
IPropertyInsepector의 어느 속성이 부울인지 알아야합니까?
감사합니다, 조 그것을했다
감사합니다. –