In Entity Framework is it possible to add a value to existing value in the database? Currently I have this:
var ent = this.repository.GetSingle(id);
var moreQuantity = 5; // This is calculated in application logic
ent.quantity = ent.quantity + moreQuantity;
this.repository.SaveChanges();
It is possible to do the same in a single database interaction? I mean something like this in SQL:
UPDATE table SET quantity = quantity + {moreQuantity} WHERE id = {id}
Without using ExecuteSqlCommand or ExecuteStoreQuery.
The reason I am asking this is because there is a significant amount of time between the GetSingle and SaveChanges in my application, so I run with some concurrency problems. I manage to solve it with RowVersion and ConcurrencyCheck but I was looking for a better implementation.
Thanks in advance.