我想查看并修改通过changeInterceptor中的PUT动词提交的信息。
例如,我可能想要在更新dataSource之前擦除传入的所有值。
或许我可以通过java脚本调用数据服务,而不是传递对象的所有当前属性,而是在服务器上完成值。
...洙
OnChangeMyObject<MyObject,Update...>{
if(UpdateOperations == UpdateOperations.change){
MyObject == the object to be updated but not the object passed in from the
caller. How can I access the object from the caller?
}
}
答案 0 :(得分:2)
我认为你可以在你的变更拦截器中做这样的事情:
if (operations == UpdateOperations.Change)
{
CurrentDataSource.SavingChanges += (o,e) => ValidatePutData(yourEntityObject);
}
方法ValidatePutData检查更改的对象数据。当EF保存您的更改时,将调用该方法。在那个时间点,实体对象的实例包含与PUT请求一起传输的新数据。