简体   繁体   English

具有自引用实体的UpdateGraph

[英]UpdateGraph with self referencing entity

I'm using GraphDiff with EF to update state of disconnected objects acquired from a REST Service. 我正在使用带有EF的GraphDiff来更新从REST服务获取的断开连接对象的状态。

It's working rather well from now but I got a problem with self referencing entities. 从现在开始,它运行良好,但我遇到了自引用实体的问题。

Entities : 实体:

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 call : UpdateGraph调用:

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

Well this last graph call only updates 1 level of recursivity. 好吧,这最后一个图调用仅更新1级递归。 How would I go to update no mater how deep the recursion is ? 我将如何不加更新地更新递归的深度?

GraphDiff currently doesn't support mapping of recursive relationships of non-predetermined depth via the fluent API. GraphDiff当前不支持通过流畅的API映射非预定深度的递归关系。 Also the new attribute based mapping will throw an exception because of a circular graph. 同样,基于圆形的新基于属性的映射也会引发异常。 So I'm afraid you can't map this right now, but I've opened an issue and will have a look if adding support for this is possible. 因此,恐怕您现在无法对此进行映射,但是我已经提出了一个问题 ,请看看是否可以添加对此的支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM