问题描述
我想添加一个事件侦听器(I preUpdateEventListener)加NH,但我似乎无法找到使用流利的配置时的一个例子。
I want to add an event listener (IPreUpdateEventListener) to add NH but I can't seem to find an example when using a fluent configuration.
我希望能够添加监听器,当我创建的会话工厂,例如:当以下code是执行。
I want to be able to add the listener when I create the session factory, e.g. when the following code is execute.
_sessionFactory = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(的connectionString).ShowSql()) .Mappings(米=> m.FluentMappings.AddFromAssemblyOf()) .BuildSessionFactory();
任何人都知道如何做到这一点?
Anyone know how to do this?
推荐答案
晚答案,发现你的问题,当我试图做同样的。发现应该是一个解决方案:
Late answer, found your question when I was trying to do the same. Found a solution that should work:
_sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005.ConnectionString(connectionString).ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Entity>())
.ExposeConfiguration(c => c.EventListeners.PreUpdateEventListeners = new IPreUpdateEventListener[] {new AuditEventListener()});
这篇关于如何通过功能NHibernate添加事件监听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!