Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok i'm saving my task in the db context simplified code below, basically i add a note to the db, and then i goto load a task up, which has navigation property of a list of notes, but when i load the task after saving changes, the newly added note doesn't show:

C#
private TaskContext db = new TaskContext();
Note note =  new Note();
// add the property values;

db.IT_Notes.Add(task);
db.SaveChanges();


then i access a Task in the DB a list of tasks
C#
Task tasks = db.IT_Tasks.FirstOrDefault(t => t.IT_TaskID == note.IT_TaskID);


i know in the past i've had to use db.Entry(passInEntryObject).Reference(nameOfProperty).Load();
but surely i dont have to do this here do i? does this reference force the new changes to be added too? is the context out of date and thats why you need to load the specifically? i thought every context command was live, not from what it was when the action result was called.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900