开发者

How to delete slave entity in entity framework poco in one line?

开发者 https://www.devze.com 2022-12-19 14:07 出处:网络
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 entiti

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

精彩评论

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

关注公众号