c# - merging two lists<T> and compare -
possible duplicate:
comparing 2 list<>
emp_db_snapshot
- loading db fresh copy of user have selected in past:
emp_selected_by_user
- user selected list, user may change selected or may add more list of may remove list:
//let have 2 rows in list. list<employee> emp_db_snapshot = new list<employee>(); emp_db_snapshot = employeelistfromdb ; //loads list db //let have 2 rows in list. list<employee> emp_selected_by_user = new list<employee>(); emp_selected_by_user = myselectedemployee //loads list selected user. //merging 2 lists: //got total of 4 rows. list<employee> allemployee = emp_db_snapshot.union(emp_selected_by_user).tolist();
so question is:
how can differentiate or compare ?
i make attempt answer question.
you make collection of differences between each collection if happen have of same data.
var differenceslist = lista.where(x => !listb.any(x1 => x1.id == x.id)).union(listb.where(x => !lista.any(x1 => x1.id == x.id)));
you suppose @ point find intersection between collections , merge result list of differences. allow have single collection data appearing once.
Comments
Post a Comment