UpdateGraph with self referencing entity

entity-framework graphdiff self-referencing-table

Question

I'm using GraphDiff with EF to update state of disconnected objects acquired from a REST Service.

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 :

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. How would I go to update no mater how deep the recursion is ?

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

Accepted Answer

GraphDiff currently doesn't support mapping of recursive relationships of non-predetermined depth via the fluent 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.

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