I have a comma seperated values (1, 2, 5, 8) and I am converting them into an array like this
string s =checkboxId.Value;
int[] nums = Array.ConvertAll(s.Split(','), int.Parse);
I want to delete all this rows where id is in nums. How can I do this with LINQ?
Tried this:
foreach(int id in nums)
{
DeleteById(id, uid);
}
public void DeleteById(int id, string userName)
{
long uid = common.GetUserId(userName);
IEnumerable<M> idList = dataContext.MD.Where(m => m.ID == id && m.UserId == uid);
dataContext.MD.DeleteAllOnSubmit(idList);
dataContext.dc.SubmitChanges();
}
EDIT: I do not want to loop through every array item. Is there a way where I can easily pass the array and delete all the records from the database through LINQ query?