LinqToSQL2 icon indicating copy to clipboard operation
LinqToSQL2 copied to clipboard

Delete multiple rows directly by Query

Open MikaelEliasson opened this issue 10 years ago • 1 comments

Something similar to:

db.SetX.DeleteWhere(b => b.Created < limit && b.Title == "T2.0");

The code to generate the filter is already there. The tricky part is that delete is a bit more complicated with joins than select is. If there are any local entities (do you have those in L2S?) that match the predicate I guess they should be deleted too.

In EFUtilities I decided to have this kind of operations outside the DbContext because they are "power functions" + work differently from the normal workflow. Not sure what would be best.

MikaelEliasson avatar Jan 09 '15 15:01 MikaelEliasson

Good idea!

FransBouma avatar Jan 09 '15 17:01 FransBouma