我正在使用Spring.NET AOP来确定C#持久对象何时更改了它的任何属性(在Spring.NET/examples中根据Spring.AopQuickStart.Step6.2010),但是我得到了MappingException - No persister for:DecoratorAopProxy_8aa4d47e877a48b4828bf7a6a51bbedf
这是我的代码:
var person = Repository.GetById(personId);
var personProxy = GetProxy(person);
// udpate some properties in personProxy - this is where my advisor determines if/what has changed
Repository.Save(personProxy); // exception thrown here
以下是GetProxy的样子(根据AopQuickStart示例):
private static Person GetProxy(Person target)
{
var proxyFactory = new Spring.AOP.Framework.ProxyFactory(target);
proxyFactory.AddAdvisor(new ModificationAdvisor(target.GetType()));
proxyFactory.AddIntroduction(new IsModifiedAdvisor());
proxyFactory.ProxyTargetType = true;
return (Person)proxyFactory.GetProxy();
}
我认为问题是传递给NHibernate会话Save的对象的GetType是“DecoratorAopProxy”,而不是抛出NHibernate的Person。
我该如何解决这个问题?
答案 0 :(得分:0)
查看DataBindingIntercepter.cs和DataBindingFactory.cs的实现
https://github.com/ayende/Effectus/tree/master/Effectus/Infrastructure