I want to delete multiple records in single linq query. I find the way but its using foreach loop to delete. I want the way like sql delete all the records in single query.
Asked
Active
Viewed 1,232 times
-3
-
DbSet.RemoveRange ? https://msdn.microsoft.com/en-us/library/system.data.entity.dbset.removerange(v=vs.113).aspx – Raphaël Althaus Jul 05 '16 at 08:48
-
Possible duplication: http://stackoverflow.com/questions/2519866/how-do-i-delete-multiple-rows-in-entity-framework-without-foreach – Andriy Tolstoy Jul 05 '16 at 08:50
-
have you seen this one: http://stackoverflow.com/questions/870216/best-way-to-delete-multiple-records-in-a-linq-query – love thakker Jul 05 '16 at 08:51
1 Answers
-2
Below link may help you, please have a look at it
obj.tblA.Where(x => x.fid == i).ToList().ForEach(obj.tblA.DeleteObject); obj.SaveChanges();
How to Delete multiple records in Linq to Entity?
Regards, Meet