我正在使用GraphDiff和 EF 来更新从 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 级递归性。无论递归有多深,我将如何更新?