c# - LinqToEntity - updating all records -
c# - LinqToEntity - updating all records -
i'm going modify 1 property in records of 1 database table , don't want materialize of records (as done method tolist() , iterating through collection of entities, , commit). utilize ef (5.0, net 4.0) , linq (thus linqtoentity).
i mean want find linq counterpart next sql statement:
update table set property='newvalue'; is possible?
you can run sql code through context without using db.savechanges:
using(var db = new yourdbcontext()) { db.database.executesqlcommand("update table set property='newvalue'"); } if need parameterize value(s) can well:
db.database.executesqlcommand("update table set property=@property", new sqlparameter("@property", somevariable)); c# sql .net linq entity-framework
Comments
Post a Comment