c# - Saving a root object in Entity Framework 6 (but not the entire context) -


i try save root object in entity framework, not objects of context. seems basic feature of entity framework , not see how it.

i use following generic dbcontext

class genericcontext<t> : dbcontext {   dbset<t> objs;    savechanges( icollection<t> validatedobjs )   { ...   } } 

my question : how can implement savechanges method in order save validatedobjs thoses related t ?

t root object of data grape.

all objects of context not related validatedobjs must not saved, if in modified state.

if t has not been modified object related t has been modified, need saving made.

for example if t = car

class car {    ilist<wheel> wheels; }  // changing color of 1 wheel: car car1 = new car(); car car2 = new car(); car1.wheels[0].color = color.red; car2.wheels[0].color = color.blue; 

we have:

entry( car1 ).entitystate = unchanged entry( car2 ).entitystate = unchanged entry( car1.wheels[0] ).entitystate = modified entry( car2.wheels[0] ).entitystate = modified 

if uservalidated contains car1 not car2, wheels of car1 must saved in database.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -