entity-framework-coreentity-framework-plus

Does ef core plus support batch update with minus?


I want to update stock quantity, such as +1, because so many requests do the same thing, and I don't want to lock the row for performance, then SQL which I wanted is :

Update Stock 
Set qty = qty + 1
where id = xxxx

Does Entity Framework Core Plus support it, or how to implement it?


Solution

  • I think its obvious

    db.Stock
      .Where(x => x.Id == id)
      .Update(x => new Stock { qty = x.qty + 1 });