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 ?
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.