我想添加一个事件监听器 (IPreUpdateEventListener
) 来添加 NHibernate,但我似乎找不到使用流畅配置的示例。
我希望能够在创建 session 工厂时添加监听器,例如当执行以下代码时。
_sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005.ConnectionString(connectionString).ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<IEntity>())
.BuildSessionFactory();
有人知道怎么做吗?
最佳答案
所以,延迟响应,但为了后代,在不删除现有注册监听器的情况下添加监听器(就像 Bengt Be 之前的回答一样):
var config = new Configuration ();
config.AppendListeners (ListenerType.PreUpdate, new [] { new AuditEventListener () });
等等
关于c# - 如何通过 Fluent NHibernate 添加事件监听器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1433638/