I have a list of ids
IEnumerable<long> ids
How can I delete from a table where the ID matches?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The “standard” way according to the MSDN docs is to use those IDs to pull up each of the objects, then delete them with the DeleteObject command:
This will produce N+1 roundtrips to the DB. This is a common downside of ORMs; they’re excellent at 99% of everyday use of SQL by an app (querying for results, creating/updating/deleting single objects) but are not really designed for these bulk operations.
You could also construct a query using ExecuteStoreCommand, where you
"DELETE FROM table WHERE id IN @p1"and specify the list of IDs as a parameter.