entity framework - Updating a set of records in LINQ - All at once -


i have several records need updated same value. if using ado.net call stored procedure updated them @ 1 ...

update mytable set mycolumn = "xxxxxx" filtercolumn == 'yyy' 

but since using entity framework wondering if similar way update set of records @ once without having loop through each of values , set them individually? using..

from s in mytables s.filtercolumn == 'yyy' select s;  var results = s.tolist();  foreach (i in results){   s.mycolumn = "xxxxxx" } 

is there way set values @ once in sql?

i using entity framework v6.1

you can still execute sql command when using entity framework. here how it.

dbcontext.database.connection.open(); var cmd = dbcontext.database.connection.createcommand();  cmd.commandtext = @"update mytable set mycolumn = @mycolumn filtercolumn = @filtercolumn";  cmd.parameters.add(new sqlparameter("mycolumn", "xxxxxx")); cmd.parameters.add(new sqlparameter("filtercolumn", "yyy")); cmd.executenonquery(); 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -