c# - EF 4.1 Code first - Many to Many - State unchanged -


i have many many relationship, see scenario explained here before continuing reading: ef 4.1 code first: many many

ok, can add entries respective tables doing solution proposed slauma (see below) not want insert entry 1 of tables (table b) has fixed entries (readonly). how achieve it? mark unchanged not working.

i following:

a = new a() { propertya1 = something_1,             propertya2 = something_2,             propertya3 = something_3 }; a.bs = new list<b>();  foreach (.....) {   b b = new b() { ..... }   a.bs.add(b); }  context.a.add(a);  // below loop not working foreach (var entry in context.changetracker.entries()         .where(e => e.state == entitystate.added && e.entity someentity)) {         entry.state = entitystate.unchanged; }  context.savechanges(); 

if remove previous foreach, information added correctly tables , link table c, in b , no want info added in b.

any ideas?

where do

b b = new b() { ..... } 

you must in stead fetch existing b database , add a.bs.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -