comparing two List<>

后端 未结 4 1129
栀梦
栀梦 2021-01-24 06:16

i have gridview control with a checkbox on it

When i hit on save button i able to find the checkbox which have been checked and i able to do it so far so good but the pr

4条回答
  •  甜味超标
    2021-01-24 06:47

    You want something like this:

    var diff = selectedEmployee.Except(listFromDb, (a,b)=>a.id==b.id);
    foreach (Employee e in diff)
    {
        EmployeeService.SaveEmployee(e.Id, e.Name);
    }
    

    but you're awful short on particulars. What defines a change? How will match items in the list: by id? Can you be more exact with your requirements?

提交回复
热议问题