I have a LINQ database operation that looks like this:
using (SomeDC TheDC = new SomeDC())
{
var SomeData = (from .... select x).ToList();
if (SomeData.Count() > 0)
{
foreach (.... in SomeData) { x.SomeProp = NewProp; }
TheDC.SubmitChanges();
}
}
As you can see, I'm reading a list, then I'm updating this list, and finally I'm writing it back to the DB. Is there a way to combine this operation in just one query?
Is there a way to combine this operation in just one query?
Not in Linq - you could execute one SQL statement directly if there's a pattern to the updates, but querying and updating are two separate methods.