I have a .Net 3.5 Windows application written in c# using the entity framework and I am struggling badly with updating. In the DB I have Job and Status tables where there is a FK from Job.StatusID to Status.ID. In my appplication I have two corresponding entities and I am fine with retrieving them and adding new.
I am creating and disposing objectcontexts as needed. To retrieve a Job I have a Get() method as shown in the first code snippet. This works great. The problem is when I want to update a reference. I can't go Job.Status = newStatus where new status is from a similar Get() method as they are from different contexts so it blows up. Also, I can't have a Job.SetStatus(Status newStatus) as that will simply crack open new contexts and the original Job object won't be updated.
I am desperate to get these basics working!
public static Job Get(string name)
using (var db = new CanDoAndonEntities())
res = (from j in db.Job
where j.Name == name