Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delete all child elements using linq to sql?

Is there an easy way to delete all child records for an item using Linq to sql?

like image 207
Abe Miessler Avatar asked Aug 09 '10 16:08

Abe Miessler


1 Answers

Something like this will work if there is a relationship between the tables:

var parent = // ...
context.Children.DeleteAllOnSubmit(parent.Children);
context.SubmitChanges();
like image 95
kbrimington Avatar answered Nov 05 '22 21:11

kbrimington