使用数组删除多个记录 [英] Delete multiple records using an Array
本文介绍了使用数组删除多个记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要有关如何使用数组删除多个记录的帮助,这是我要尝试处理的代码
I need Help on how to delete multiple record using an array, here is the code i am trying to work on
TableEmployee e = TableEmployee.GetAllEmployeeByID(ID);
e.Delete();
DataBind();
上面的代码仅适用于单个记录,但是,我想在这里实现的是,使用foreach循环来获取多个雇员并将其全部删除.
谢谢
Chetan.
The Code above works only for a single record but, what i want to achieve here is, use a foreach loop to get multiple employees and delete them all.
Thank you
Chetan.
推荐答案
通过一个ID获取所有雇员听起来适得其反.一名员工有一个唯一的ID.因此,当您调用一个函数的名称时,该函数的名称暗示该函数应返回employeeessm的集合,您需要除ID以外的其他参数.然后,该函数还应该返回某种类型的集合(例如List<Employee>
).然后,您可以遍历该列表,并根据需要删除它们!
干杯!
-MRB
Getting a all employees by one ID sounds counter productive. One employee has a one unique ID. So when you call a function the name of which implies that it is supposed to return a collection of employessm you need some other parameter than ID. That function should then also return some sort of collection ( like for instance aList<Employee>
). You can then iterate over that list and delete them as it pleases you!
Cheers!
-MRB
我想您也应该尝试使用LINQ在此处选择和删除记录.
I think you should also try and look at using LINQ to select and delete records here.
这篇关于使用数组删除多个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文