zzzprojects / GraphDiff

GraphDiff is a library that allows the automatic update of a detached graph using Entity Framework code first.
https://entityframework-graphdiff.net/overview
MIT License
333 stars 101 forks source link

3d level association does not work. #158

Open cryo75 opened 8 years ago

cryo75 commented 8 years ago

I have the following classes:

Customer
CustomerAddress
PostCode
State

On saving a customer with an address I do:

customer = dbContext.UpdateGraph<Customer>
            (entity, map => map.OwnedEntity(x => x.CustomerAddress, with => with.AssociatedEntity(x => x.PostCode)));   

This works because State is associated to PostCode and PostCode is associated to state.

However, when GraphDiff reloads the saved entities, the state is null. So I tried:

customer = dbContext.UpdateGraph<Customer>
            (entity, map => map.OwnedEntity(x => x.CustomerAddress, with => with.AssociatedEntity(x => x.PostCode).AssociatedEntity(x => x.PostCode.State));   

This does compile but it does not work, because it throws an exception about include paths.on other entities unrelated to the address.

Is there a way to solve this issue of associating a 3rd level?