开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜