這裏
http://msdn.microsoft.com/en-us/library/dd744842.aspx
當添加changeInterceptor到實體叫你將有機會獲得其狀態,並根據其狀態,你可以執行你的任務所示。你可以利用ChangeInterceptors中的OData示例這裏是我的一個實體的變更攔截器,「術語」
[ChangeInterceptor("Term")]
public virtual void OnChangeTerm (Term reqObj, UpdateOperations operations){
OnChangeInterceptor<Term>(reqObj, operations, CurrentDataSource);
}
protected virtual void OnChangeInterceptor<TEntity>(TEntity entity, UpdateOperations operations, IDataContext currentDataSource)
{
switch (operations){
case UpdateOperations.Add:
ServiceController.OnAddEntityRequest(entity, currentDataSource);
break;
case UpdateOperations.Change:
ServiceController.OnUpdateEntityRequest(entity, currentDataSource);
break;
case UpdateOperations.Delete:
ServiceController.OnDeleteEntityRequest(entity, currentDataSource);
break;
}
}