我有2個物品清單;通過使用linq比較兩個列表進行排序?
IEnumerable<Investigator> investigators = RepositoryContext.InvestigatorRep.GetInvestigators(site.Site.Id, out totalCount);
var NewInvestigators = base.ActivePage.Investigators;
我有30項在調查員和20項在NewInvesigators,都有屬性Id,InvId我需要匹配。
var all = investigators.Where(b => crInvestigators.Any(a => a.InvestigatorId == b.Id));
我嘗試這樣做但不工作的 我想創建基於這兩個列表的匹配ID的新名單。如果Id匹配得到特定調查員(基本上是根據NewInvesigators中存在的Id調查員)。
我可以使用每個做,但我想知道是否有可能與linq
?
in newinvestigator我有兩個屬性的對象,investigatorId和Name。
調查員我有財產ID,城市,國家。 否調查員名單中的姓名或研究員ID。
是使用淳佳n in linq –
[LINQ查詢以查找列表中的項目是否包含在另一個列表中]的可能重複(http://stackoverflow.com/questions/12656582/linq-query-to-find-if-items-in-一個列表,被包含的功能於另一個列表) –
有可能使用LINQ很明顯。用加入 – Viplock