RSS

Delete all or n Rows from a table Entity Framework

31 Dec

write a method DeleteAll in your table repository class, if one is there.

public void DeleteAll()
{
table1Repository.Entities.table1.RemoveRange(table1Repository.Entities.table1.AsEnumerable().Where(cb => cb.Id > 0));
table1Repository.Entities.SaveChanges();
}

 
Leave a comment

Posted by on December 31, 2018 in asp.net, Entity Framework, MVC

 

Leave a comment