1

ChangeInterceptor()の内部でエンティティの関係がどのように影響され/変更されたかを確認する方法はありますか?ここでは、NorthWindデータベースを使用して、関係が一対多である従業員エンティティから注文エンティティを削除/削除した場合の例を示します。従業員には多くの受注があり、受注の検出方法はどのようにして従業員エンティティから削除されました。 ObjectStateEntryクラスを使用して、GetModifiedProperties()を呼び出してPropertiesの変更内容を知ることができますが、Collections/Associationsがどのように変更されたのかはわかります。 RelationshipManagerと関係がありますか?ChangeInterceptorを使用してエンティティ間の "関係"変更/突然変異を検査する

[ChangeInterceptor("Employees"] 
public void OnChangeEmployees(Employee employee, UpdateOperations operations) 
{ 
    //I'm using EntityFramework 4.1 
    //We have to dropdown the ObjectContext to detect IA, Independant Association, changes 
    ObjectContext ctx = ((IObjectContextAdapter)this.CurrentDataSource).ObjectContext; 

    ObjectStateEntry entry = ctx.ObjectStateManager.GetObjectStateEntry(employee); 

    //What do I do here for detecting relationship changes.. I.E and Order was added? 


} 

ありがとうございます。

答えて

0

ChangeInterceptorを使用する代わりに、ObjectContextにSavingChangesイベントハンドラを実装するだけです。このarticleは、エンティティの関係が影響を受けているかどうかを調べる方法を説明しています。

関連する問題