Eugeniu Torica
Eugeniu Torica

Reputation: 7574

Update query with entityframework

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?

Upvotes: 2

Views: 1227

Answers (3)

Craig Stuntz
Craig Stuntz

Reputation: 126547

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

Upvotes: 2

Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65371

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.

Upvotes: 5

Lloyd
Lloyd

Reputation: 1324

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.

Upvotes: 3

Related Questions