I have the following linq:
var wcd = dbContext.Programs.Where(p => p.Id == Id).ToList();
dbContext.DeleteObject(wcd);
SaveChanges();
I get a message saying that I do not have a definition for DeleteObject in my Model.
I can though do SaveChanges(),etc.
I tried the following:
var wcd = dbContext.Programs.Where(p => p.Id == Id).ToList();
dbContext.Programs.Remove(wcd);
but I get the following
The best overloaded method match for ‘System.Data.Entity.DbSet
.Remove has some invalid arguments
Is it a DbContext? If so you’re going to need to use Remove which is part of your DbSet:
EDIT:
You need to loop through your list and remove then individually: