FransBouma / LinqToSQL2

Official Linq to SQL fork. A complete ORM which is backwards compatible with Linq to SQL but with new features.
Other
57 stars 22 forks source link

Delete multiple rows directly by Query #16

Open MikaelEliasson opened 9 years ago

MikaelEliasson commented 9 years ago

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.

FransBouma commented 9 years ago

Good idea!