entity framework - How to update a field using its own value with only one query? -


considering folling query:

update t1 set p1 = p1 + 10 id = @id 

how can achieve same behaviour in entityframework 1 query?

currently, doing this:

    var obj = bd.objs.single<objclass>(x=> x.id == id);     obj.p1 = obj.p1 + 10;     bd.savechanges(); 

but wastes db access querying object

well, there way it, need use 3rd party library (entity framework extended library)

context.objs     .where(t => t.id== id)     .update(t => new obj{ p1= t.p1+10 }); 

this nuget package need install. library eliminates need retrieve , load entity before modifying it. can use delete or update entities.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -