SiberianGuy
SiberianGuy

Reputation: 25312

Self-Tracking Entities Clear collection

I have a STE and I want to clear navigation property collection like customer.Orders.Clear(). But Clear doesn't mark orders as Deleted so they won't be deleted on ApplyChanges call. Is there any built-in way to clear orders and mark all of the as Deleted?

Upvotes: 1

Views: 212

Answers (1)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364409

This is general behavior in entity framework. Clearing navigation property will only break the relation but entity itself will not be deleted. In case of common entities this can be avoided with very strange mechanism called identifying relation - I'm not sure if this works in the same way with STEs. So I think the answer to your question is no, you must iterate related entities and call MarkAsDeleted on each of them.

Upvotes: 2

Related Questions