E
Eric Falsken
*background*
I've got an application that I'm creating that is using LINQ to SQL. We have
a nice DataContext that is able to do lots of nice updating. But we are using
something like an MVC model where the controllers are doing the updating.
Since objects have to be updated/deleted to the same CataContainer that they
were retreived from. So to solve "attach" and "detach" issues, we just make
sure that the "Controller" in our setup is static. (using the Provider model)
*question*
But now that the Context is shared among all our requests, calling
DataContext.Submit() will submit ALL changes to ALL objects that came from
the DataContext, even if the changes are incomplete or in the process of
being made still. Heck, some changes might not even get past validation. How
can I call Submit() to apply some changes but not others? Is there some way
to do this with transaction sopes? e.g.
MyObject obja = context.Table.First();
MyObject objb = context.Table.Second();
objb.Name = "name2"; //could be happening in another thread
using (TransactionSope ts = new TransactionScope()){
obja.Name = "name1";
context.Submit(); //objb should not be updated here
}
I've got an application that I'm creating that is using LINQ to SQL. We have
a nice DataContext that is able to do lots of nice updating. But we are using
something like an MVC model where the controllers are doing the updating.
Since objects have to be updated/deleted to the same CataContainer that they
were retreived from. So to solve "attach" and "detach" issues, we just make
sure that the "Controller" in our setup is static. (using the Provider model)
*question*
But now that the Context is shared among all our requests, calling
DataContext.Submit() will submit ALL changes to ALL objects that came from
the DataContext, even if the changes are incomplete or in the process of
being made still. Heck, some changes might not even get past validation. How
can I call Submit() to apply some changes but not others? Is there some way
to do this with transaction sopes? e.g.
MyObject obja = context.Table.First();
MyObject objb = context.Table.Second();
objb.Name = "name2"; //could be happening in another thread
using (TransactionSope ts = new TransactionScope()){
obja.Name = "name1";
context.Submit(); //objb should not be updated here
}