How to handle deep objects using the EF + Web API?

This is my first question, so be careful.

I have a database model consisting of 60 objects that describe information and various features of an industrial process. The end result is approx. 10-level deep objects.

My intention was to

  • send top-level object to client in JSON
  • two-way binding of the specified object (in angular, but nvm it) and manipulate it
  • force client AJAX calls to reference this top-level object
  • rebuild the specified object through one or two constructor calls in the web API
  • modify an object and save changes using the top-level object method

My solution was to create an extra layer of objects based on EF to allow excluding / adding data from / to objects sent to the client at will, bypassing problems with circular links and other problems caused by impatience / lazy loading. These objects are passed to the web API.

Now, where does the problem begin: as a result of an additional layer, restoration of EF objects from an additional layer is necessary when saving changes to EF objects in a chain. It’s getting harder to keep up with all this.

. EF ? , JavaScriptSerializer ( FK )? , .

?

+4
1

, , . , .

, Id - .
JavaScript, Id , , .
, , .

.

, , ( 10 ).


JavaScriptSerializer

, . , , , .

+2
source

Source: https://habr.com/ru/post/1624588/


All Articles