1 回答
TA贡献1820条经验 获得超2个赞
您需要的是连接,而不是相交。
var CommonList = iMIScustomersList.Join(zendeskCompaniesList,
cust=>cust.Company,
comp=>comp.Name,
(cust,comp)=> new {Customer=cust,Company=comp}).ToList();
例如,
var iMIScustomersList = Enumerable.Range(1,10)
.Select(x=> new Customer{Name = $"Name{x}", Company=$"Company{x}"});
var zendeskCompaniesList = Enumerable.Range(5,10)
.Select(x=> new Company{Name=$"Company{x}", Location = $"Location{x}"});
var CommonList = iMIScustomersList.Join(zendeskCompaniesList,
cust=>cust.Company,
comp=>comp.Name,
(cust,comp)=> new {Customer=cust,Company=comp}).ToList();
样本输出
- 1 回答
- 0 关注
- 121 浏览
添加回答
举报