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

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -