如何使用linq到sql删除所有子元素?

时间:2021-08-08 09:18:20

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

是否有一种简单的方法可以使用Linq to sql删除一个条目的所有子记录?

1 个解决方案

#1


6  

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

如果表格之间有关系,类似这样的东西就会起作用:

var parent = // ...
context.Children.DeleteAllOnSubmit(parent.Children);
context.SubmitChanges();

#1


6  

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

如果表格之间有关系,类似这样的东西就会起作用:

var parent = // ...
context.Children.DeleteAllOnSubmit(parent.Children);
context.SubmitChanges();