What is the best way to remove multiple records in one go with LINQ?
This is what I used, first create an IENumerable object of the table where are the records to be removed are, then just use RemoveRange, and finally just save changes to database. Let's say you want to remove all products from one specific supplier ID on the Products table, this is how you could do that.
IEnumerable ProductsToRemove= db.Products.Where(x => x.SupplierId== Supplierid); db.Products.RemoveRange(ProductsToRemove); db.SaveChanges();