Is there any smart way to do this?
If using Linq2Nhibernate, you really seem to have to rely on HQL or the likes to do multiple deletes from a database (without loading up and deleting one by one)?
It doesn’t seem like Linq2Sql have it either? I just want something that can do stuff like:
DELETE FROM Accounts WHERE amount < 1000
Any ideas?
The short answer is: you can’t.
You can do something like:
But, because the framework needs to track concurrency issues it will always execute separate deletes (so if you have 500 rows that would be deleted, it will send 500 delete statements)
For a longer version and a solution see: http://www.aneyfamily.com/terryandann/post/2008/04/Batch-Updates-and-Deletes-with-LINQ-to-SQL.aspx