使用linq查询两个排序列表

时间:2013-08-14 18:50:12

标签: vb.net linq

我将带有wmi的修补程序列表放入一个已排序列表中。然后,我在另一个从http://support.microsoft.com/kb/2545685

构建的列表中进行了群集修复
Dim p_Windows2008R2sp1ClusterFixes As New sortedList
p_Windows2008R2sp1ClusterFixes("2525380") = ""
p_Windows2008R2sp1ClusterFixes("2446607") = ""
p_Windows2008R2sp1ClusterFixes("2531907") = ""
p_Windows2008R2sp1ClusterFixes("2550886") = ""
p_Windows2008R2sp1ClusterFixes("2552040") = ""
p_Windows2008R2sp1ClusterFixes("2520235") = ""
p_Windows2008R2sp1ClusterFixes("2494162") = ""
p_Windows2008R2sp1ClusterFixes("2524478") = ""
p_Windows2008R2sp1ClusterFixes("2494162") = ""

Dim hotfixArray As String() = {981391, 981392, 977236, 981111, 977238, 977239 }
For i As Integer = 0 To hotfixArray.Length - 1
          slMissingList(hotfixArray(i)) = hotfixArray(i)
Next

我希望能够进行内部联接以查看已安装的修复程序和使用linq的左外部联接来告诉我未安装的修补程序。 在1到16台机器上有几百个修复程序。我需要能够看到每台机器的修复程序。

1 个答案:

答案 0 :(得分:0)

您可以使用Where完成所需的工作。很难从你的问题中看出哪个列表包含了什么,但它看起来像是:

   Dim available As New SortedList(Of string,string)
   Dim installed As New SortedList(Of string,string)

   Dim availableInstalled = available.Where( Function(a) installed.ContainsKey(a.Key))
   Dim missing = available.Where( Function(a) Not installed.ContainsKey(a.Key))