Can GraphDiff be used for partial updates of simple entities too?

asp.net-web-api2 c# entity-framework graphdiff

Question

I have a WebApi2 project with EF6 CodeFirst. I'm also using AutoMapper to map between my models and dto's. I'm not using OData.

I'm trying to find a solution to handle updates of entities. As I'm not using OData I can't use Delta and I would not like to use JsonPatch.

In my scenario:

  1. Client sends the data (as dto) to the server
  2. Server loads the associated entity / entity graph from the DB using EF
  3. Server should patch the entity with values of the dto
  4. Server saves the patched entity and EF should take care of change tracking

My problem lies with 3.

Can I use GraphDiff for patching entities? (I will also be using GraphDiff was updating complex graphs). And if I can use GraphDiff, will EF change tracking kick in automatically?

1
2
1/27/2015 1:55:39 PM

Accepted Answer

In the above-mentioned scenario:

  1. As above
  2. Server maps from dto to model and passes model to service/repository
  3. Graphdiff will load the model before updating and will take care of changed properties accordingly
  4. Graphdiff will return the updated entity

As for (3):

GraphDiff does not do a per-property patch. It updates the whole object by traversing it and build a diff and then it merges the changes. As the loaded graph is tracked by EF, it is then EF's task to send the correct SQL statements.

2
7/21/2016 4:52:07 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