How to delete an object by id with entity framework
Posted
by Jeff
on Stack Overflow
See other posts from Stack Overflow
or by Jeff
Published on 2010-03-18T16:11:54Z
Indexed on
2010/03/18
16:21 UTC
Read the original article
Hit count: 322
entity
|entity-framework
It seems to me that I have to retrieve an object before I delete it with entity framework like below
var customer = context.Customers.First(c => c.Id = 1);
context.DeleteObject(customer);
context.Savechanges();
So I need to hit database twice. Is there a easier way?
Thanks
© Stack Overflow or respective owner