views:

212

answers:

1

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 framework 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 framwork?

A: 

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.

Craig Stuntz