entity framework - Adding Data to a very nested child object using EntityFramework -


enter image description here

i trying add note event object. getting error using code

  note notetoadd = new note { state = state.added, notetext = note };   patient patient = context.patients.find(patientid);   patient.state = state.modified;   patient.mobilepatient.state = state.modified;   patient.mobilepatient.mcalmevents.find(e => e.id == eventid).note = notetoadd;   context.applystatechanges(); 

is there better way using linq entity?

the error having :

{"invalid column name 'note_id'."}

and sql being generated select instead of insert.

thank you

but map shows one-to-many relation between note , event...

all of code remain are, instead of line :

patient.mobilepatient.mcalmevents.find(e => e.id == eventid).note = notetoadd; 

replace these lines:

notetoadd.eventid = oevent.id; // replace field names, are;  context.note.add(notetoadd); var oevent = patient.mobilepatient.mcalmevents.find(e => e.id == eventid); oevent.noteid = notetoadd.id; // replace field names, are;     

also think if don`t write these two:

var oevent = patient.mobilepatient.mcalmevents.find(e => e.id == eventid); oevent.noteid = notetoadd.id; // replace field names, are; 

there not problem, i`m not sure


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -