c# - How should one handle deep objects with EF+Web API? -


this first question here, gentle.

i have database model consisting of 60 objects describing information , various features of industrial process. end result approx. 10-level deep objects.

my intention to

  • send top level object client in json
  • two-way bind said object (in angular, nvm that) , manipulate
  • make client's ajax calls refer top-level object
  • rebuild said object via 1 or 2 constructor calls in web api
  • alter object , save changes via top-level object method

my solution create additional layer of objects based on ef ones allow omitting/adding data from/in objects being sent client @ will, circumventing issues circular references , other problems caused eager/lazy loading. these objects fed web api.

now here's trouble begins: result of additional layer, reconstruction of ef objects additional layer ones necessary whenever saving changes in ef objects down chain. getting increasingly arduous keep of this.

the objects highly interconnected , constrained. should write extensions ef objects emulate features of additional layer? if that's case, won't javascriptserializer try serialize objects in of relationships (where serialized object's key defined fk in object)? because that's i've gathered error messages.

or doing wrong?

in disconnected application yours, i'd remove all navigation properties. may seem convenient @ first, cause headaches along way.

i believe accessing entities via id way go.
can write javascript class responsible receiving entities per id , can therefore cache them.
each time need entity on client, through class.

this result in having 1 controller each entity.

another advantage don't have send , receive whole object graph, seems lot of data (10 levels deep lot).


won't javascriptserializer try serialize objects in of relationships

yes will. that's 1 reason why objects navigation properties, circular ones, difficult serialize.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -