entity framework - Adding Data to a very nested child object using EntityFramework -
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
Post a Comment