アプリケーションをカスタムORMから.Net4を使用してEntityFrameworkに変換しています。状況は順調に進んでいますが、子アイテムを別の親に移動する方法がわかりません。どのパターンに従うべきかわかりません。
ORMを使用して、次のようなメソッドを生成しました。
public void MoveTo_Item(Parent.Row destination)
{
_inMovement = true;
_parent_Item.Child_Items.Remove(this);
parent_id = destination.id;
destination.Child_Items.Add(this);
_inMovement = false;
}
どこ:
_inMovement == true
_parent_Item.Child_Items.Remove/Add(this)
DBでの削除/挿入のトリガーを防止しました。とparent_id = destination.id
DBで更新をトリガーしました。
parent1.Remove(item)
子アイテム自体には子アイテムがあるので、その後に。を続けることができるとは思わないでくださいparent2.Add(item)
。
EF .Net 4で親アイテムを適切に変更するにはどうすればよいですか?