views:

157

answers:

3

How to write an update query in EntityFramework using LINQ to Entities?

EDIT: And if it is possible how this query can be written in Entity SQL?

+2  A: 

LINQ does not support update operation. All you can do is fetch entity from database, change it's properties and submit changes back into database.

Lloyd
+3  A: 

There are 2 aternatives:

  • Same as Lloyd fetch entity from database, change it's properties and submit changes back into database.
  • Write an update statement in a stored procedure, then execute the stored procedure.
Shiraz Bhaiji
+2  A: 

Neither LINQ to Entities (nor LINQ to anything else) nor ESQL support updates.

Craig Stuntz