有兩個集合: NodesWithCircuitsDown<NetworkDeviceNodeStatus>
和RecordedImpairedNodes<NetworkDeviceNodeStatus>
。LINQ比較兩個集合的多個屬性
NetworkDeviceNodeStatus
有一個NodeId
(int)和一個CurrentStatus
(枚舉)。
我想創建第三個集合稱爲NodesWithDifferentImpairment
,將包含有NodeId
這就是在上述兩個集合的任何NetworkDeviceNodeStatus
,但有CurrentStatus
這是不同的。
下面是我到目前爲止,但我有困難嵌套查詢來完成此操作。
IEnumerable<NetworkDeviceNodeStatus> NodesWithDifferentImpairment =
NodesWithCircuitsDown.Where(x =>
RecordedImpairedNodes.Select(y => new { y.CurrentStatus, y.NodeId }).Select(y => y.NodeId)
);
您的意思是'對=> pair.LeftNode.CurrentStatus = pair.RightNode.CurrentStatus'!? – blgrnboy
@blgrnboy是的,感謝您發現這個 –
我還添加了'.Select(pair => pair.LeftNode)'以獲取一個'IEnumerable'?最終結果應該是找回'NodesWithCircuitsDown'中沒有相同CurrentStatus的項目。 –
blgrnboy