c# - Update multiple entities in MVC4 with LINQ, SQLquery -
c# - Update multiple entities in MVC4 with LINQ, SQLquery -
is possible update/remove multiples entities, illustration
[httppost, actionname("removeresponsible")] public actionresult removeresponsibleaction(responsible modelo) { responsible responsible = db.responsibles.single(x => x.responsible_id == modelo.responsible_id); db.responsibles.remove(responsible); db.savechanges(); viewbag.responsible = db.responsibles.tolist(); homecoming view("responsiblemanager"); }
this code works 1 single responsible unique id, how can if there many responsible same id? example, know sql "delete table responsible_id=3".
if using entity framework 6
can utilize removerange
method:
var responsibles = db.responsibles.where(x => x.responsible_id == modelo.responsible_id).tolist(); db.responsibles.removerange(responsibles);
c# asp.net-mvc linq entity-framework asp.net-mvc-4
Comments
Post a Comment