Conditional mapping using GraphDiff

61 Views Asked by At

I am having an issue with GraphDiff whilst saving some data and I just need some one to confirm if this is possible.

I will provide an example of what is going on:

Firstly, I am using VS2017 (latest revision) EF 6, Automapper and GraphDiff.

I have a table which contains the following data.

Table Data

As you can see this lists data for a ParcelId of 5023, the only difference is the IsAcquired and IsCurrent flags.

I am not going into the code that updates the data with the IsCurrent flag set to true as it is very complicated, but in essence, a screen allows users to enter values, that on saving sets the records in the second list from IsCurrent to False and inserts Three new records that have new values and has the IsCurrent set to True. This provides us the ability to undo these records.

Now, I have differnt screen that enables you to edit the main data, or in other words the data from the first grid.

This is using GrphDiff to update the data. The data that is in the second grid is NOT recovered for this edit, but on saving the GraphDiff opertaion is seeing that the data is different and overwriting in.

dbContext.UpdateGraph(a,map=>map.OwnedCollection(x => x.ParcelRight);

I need it to ingnore the records that an IsCurrent equals true and only update records that have IsAcquired = true.

I tried:

dbContext.UpdateGraph(a,map=>map.OwnedCollection(x => x.ParcelRight
                    .Where(r => r.IsAcquired == true).ToList());

but it did not work.

I found the following which sort of implies that it cannot be done.

Research

1

There are 1 best solutions below

0
gilesrpa On

Thanks to all that looked at this, but it looks like it is something that causes GraphDiff issues, so I have changed my code for this update to use a more traditional Linq to Entites solution.