UpdateGraph with self referencing entity

entity-framework graphdiff self-referencing-table

Question

I'm updating the state of disconnected objects I got from a REST service using GraphDiff and EF.

The way it works presently is quite good, but I have 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>();
    }
}

Graph update call

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

The recursivity of this final graph call has only been updated at level 1. No matter how deep the recursion, how would I update?

1
1
10/22/2014 3:27:27 PM

Accepted Answer

Recursive relationships with non-predetermined depth cannot presently be mapped by GraphDiff using the fluent API. Additionally, a circular graph will cause the new attribute-based mapping to produce an exception. I'm sorry, but you cannot map this at this time. However, I have opened a problem and will investigate whether adding support for this is feasible.

1
10/27/2014 10:11:28 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow