I have a record that came from the follow linq query:
using (var context = new myEntities())
{
var record = (from d in context.Student select d).SingleOrDefault();
}
I typically assign a new value to the record like this:
record.Value = SomeNewValue;
then I would do a
context.SaveChanges;
this all works fine. My question is: How can I save the same record if I pass it to another function or if the record was returned from a function? I am looking for something like this:
context.SaveChanges(record);
The operation which triggers your function in question should create and manage the
context. If it was an ASP.NET MVC app I’d encourage you to set up the context at the beginning of the request and callcontext.SaveChangeswhen it was finished. In a winforms/WPF app, you may want to keep thecontextaround for the life of the application, and callcontext.SaveChanges()after any action that could change data (like a button press).