1

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

4

1 回答 1

1

GraphDiff 目前不支持通过 fluent API 映射非预定深度的递归关系。由于圆形图,基于新属性的映射也会引发异常。所以恐怕你现在不能映射这个,但我已经打开了一个问题,如果可以添加对此的支持,我会看看。

于 2014-10-27T22:11:28.533 回答