Reputation: 303
Searching here I see
db.ProRel.RemoveRange(db.ProRel.Where(c => c.ProjectId == Project_id));
can be used to remove a set of records. However, if you want to remove a large number of records, like 1000s or more, you don't want to bring them into memory. Can Linq do it, or do you do you need to drop into SQL?
Upvotes: 0
Views: 25
Reputation: 39386
There is a 3rd party library called EntityFramework.Extended that lets you do a batch to delete a set of specific rows. In your case it would be:
db.ProRel.Where(c => c.ProjectId == Project_id).Delete();
db.SaveChanges();
Just install this nuget package and execute the code I show above.
Upvotes: 1