1

EF でGraphDiffを使用して、REST サービスから取得した切断されたオブジェクトの状態を更新しています。

今からかなりうまく機能していますが、自己参照エンティティに問題がありました。

エンティティ :

public class Foo {
    [Key]
    public int Id { get; set; }

    public virtual ICollection<Bar> Bars { get; set; }

    public Foo() {
        Bars = new HashSet<Bar>();
    }
}

public class Bar {
    [Key]
    public int Id { get; set; }

    public string Name { get; set; }

    public virtual ICollection<Bar> Children { get; set; }

    public Bar() {
        Children = new HashSet<Bar>();
    }
}

UpdateGraph 呼び出し:

DataContext.UpdateGraph(entity, map => map
    .OwnedCollection(e => e.Bars,
        with => with.OwnedCollection(b => b.Children)
    )
);

さて、この最後のグラフ呼び出しは、1 レベルの再帰のみを更新します。再帰の深さに関係なく、どうすれば更新できますか?

4

1 に答える 1