c# - EF: Increase a field by X -


i want increase quantity property of stock entity x units 10. effort using ef fails because appropriate sql statement (quantity = quantity + 10) not generated , instead (quantity = 110) generated. important in concurrent model;

var db = new warehousecontext(); stock s = db.stocks.single(p=>p.id==1); console.writeline(s.quantity); // --> 100 s.quantity += 10; db.savechanges(); 

this generates:

update dbo.stock set quantity = 110; 

but, want this:

update dbo.stock set quantity = quantity + 10; 


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -