Reputation: 51
Delete multiple rows by using the following conditions ، But the error..
Melks = Ent.Tbl_Melk.Where(d => d.Mantaghe == Mantaghe && d.Hoze == Hoze && d.Block == Block && d.Melk == Melk).All();
Ent.DeleteObject(Melks);
int r = Ent.SaveChanges();
if (r > 0)
{
return true;
}
else
{
return false;
}
Upvotes: 1
Views: 2408
Reputation: 106906
Looking at your code it seems that Melks
is a boolean variable. You cannot call DeleteObject()
supplying a boolean as the argument.
You need to remove the .All()
predicate at the end of your LINQ statement and then delete each object returned by the query:
var melks = Ent.Tbl_Melk.Where(
d => d.Mantaghe == Mantaghe && d.Hoze == Hoze && d.Block == Block && d.Melk == Melk);
foreach (var melk in melks)
Ent.DeleteObject(melk);
Upvotes: 2