c# - updating multiple records in database with linq to sql without loop, is it possible? -
ok, let want update multiple rows in database @ once, without looping, if loop, might :
var products = (from prod in context.products prod.productcategoryid == myproductid select prod).tolist(); // modify each object foreach (var product in products) { product.phonenumber = ???; product.name = ???; product.address = ???; } context.submitchanges();
is there better way this? without doing loop? consider me beginner on linq, if there better way, great if provide me example, in advance.
linq
quering records. current foreach
loop more readable , if try other approach use loop internally.
you can see this answer modifies collection using linq, not recommended way.
Comments
Post a Comment