How to delete slave entity in entity framework poco in one line?
The following code:
order.Orderlines.Remove(orderline)
Means not only to remove relationship between Order and Orderline but also to remove orderline from persistence permanently. Many slave entities have this situation.
As I know, in entity fra开发者_开发问答mework have to write extra code:
context.DeleteObject(orderline);
Or,
context.Orderlines.DeleteObject(orderline);
So, the remove rule can't be encapsulated entirely in order itself.
Any better choice for one line deletion in entity framework?
It's not entirely clear to me what you are asking, but here is a very complete description of various scenarios for deleting related entities, which will hopefully answer your question.
精彩评论