Entity Framework deletion of non-null foreign keyed rows?

If that's really not a possibility, you could try the following: Since ObjectContext doesn't have a DeleteAll style method...you could always implement your own: public static void DeleteAll(this ObjectContext context, IEnumerable records) { foreach(Object record in records) { context. DeleteObject(record); } } Then you could write something like (probably in a Repository): context. DeleteAll(context.OrderDetails.

Where(od => od. Product == product)) Or, to be a little cleaner: var toDelete = context.OrderDetails. Where(od => od.

Product == product); context. DeleteAll(toDelete).

If that's really not a possibility, you could try the following: Since ObjectContext doesn't have a DeleteAll style method...you could always implement your own: public static void DeleteAll(this ObjectContext context, IEnumerable records) { foreach(Object record in records) { context. DeleteObject(record); } } Then you could write something like (probably in a Repository): context. DeleteAll(context.OrderDetails.

Where(od => od. Product == product)); Or, to be a little cleaner: var toDelete = context.OrderDetails. Where(od => od.

Product == product); context. DeleteAll(toDelete).

Your idea in comments is cleaner than your answer. :) The EF should notice the cascade and "just work. " blogs.msdn.Com/alexj/archive/2009/08/19/… – Craig Stuntz Feb 4 '10 at 19:37 1 @Craig I only posted the answer because I didn't get any response to my comments.

I'll update my post. – Justin Niessner Feb 4 '10 at 19:42 Thanks - I think the edit to use on delete cascade if possible, otherwise manually delete cascading relationships sums this up well. – Jon Galloway Feb 4 '10 at 19:55.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions