有沒有人有一個使用非流暢NHibernate(NHibernate中的XML映射)與Castle Windsor和代碼作爲配置(Castle Windsor沒有XML)的PersistenceFacility的例子? (ASP.NET MVC)Castle Windsor,Non-Fluent NHibernate和PersistenceFacility
貫穿本教程,他們使用流利NHibernate,而我不能使用流利(我將通過* .hbm.XML配置NHibernate類)。
教程> http://docs.castleproject.org/Windsor.Windsor-Tutorial-Part-Six-Persistence-Layer.ashx
與流利具體例>https://github.com/kkozmic/ToBeSeen/blob/master/src/ToBeSeen/Plumbing/PersistenceFacility.cs
public class PersistenceFacility : AbstractFacility
{
protected virtual void ConfigurePersistence(Configuration config)
{
SchemaMetadataUpdater.QuoteTableAndColumns(config);
}
protected virtual AutoPersistenceModel CreateMappingModel()
{
var m = AutoMap.Assembly(typeof(EntityBase).Assembly)
.Where(IsDomainEntity)
.OverrideAll(ShouldIgnoreProperty)
.IgnoreBase<EntityBase>();
return m;
}
protected override void Init()
{
var config = BuildDatabaseConfiguration();
Kernel.Register(
Component.For<ISessionFactory>()
.UsingFactoryMethod(_ => config.BuildSessionFactory()),
Component.For<ISession>()
.UsingFactoryMethod(k => k.Resolve<ISessionFactory>().OpenSession())
.LifestylePerWebRequest()
);
}
protected virtual bool IsDomainEntity(Type t)
{
return typeof(EntityBase).IsAssignableFrom(t);
}
protected virtual IPersistenceConfigurer SetupDatabase()
{
return MsSqlConfiguration.MsSql2008
.UseOuterJoin()
.ConnectionString(x => x.FromConnectionStringWithKey("ApplicationServices"))
.ShowSql();
}
private Configuration BuildDatabaseConfiguration()
{
return Fluently.Configure()
.Database(SetupDatabase)
.Mappings(m => m.AutoMappings.Add(CreateMappingModel()))
.ExposeConfiguration(ConfigurePersistence)
.BuildConfiguration();
}
private void ShouldIgnoreProperty(IPropertyIgnorer property)
{
property.IgnoreProperties(p => p.MemberInfo.HasAttribute<DoNotMapAttribute>());
}
}
我需要的是PersistenceFacility配置設置的NHibernate不流利。如果有人可以演示代碼來爲不流暢的NHibernate設置NHibernate等,或者將我指向一個很棒的示例/教程/博客!