这里
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;
}
}