Add two list sequentially together according to it order... stop when end of one list.
Fast but limited compare with join.
(roleList).Zip(roleDescriptionList, (r, rd) => new RoleDescription() { roleID = r.dataID, role = r.dataValue, description = rd.dataValue }).ToList();
roleList and roleDescriptionList are two separate lists. They can be unrelated at all.
Using Zip() to join them together to create a new list of object "RoleDescription" one by one.
To have better control, you should use join instead.
IList<RoleDescription> result = (from r in roleList
join rd in roleDescriptionList
on r.dataID equals rd.dataID
select new RoleDescription {
roleID = r.dataID,
role = r.dataValue,
description = rd.dataValue }).ToList();
No comments:
Post a Comment