vb.net 使用 linq 筛选 xdoument
vb.net动态组合where条件
Dim LqGb As IEnumerable(Of XElement) = From Ele As XElement In ResponseXml.Descendants("uInfo")
Select Ele
If BID > 0 Then
LqGb = LqGb.Where(Function(w) w.Element("BID").Value = BID)
ElseIf GID > 0 Then
LqGb = LqGb.Where(Function(w) w.Element("GID").Value = GID)
End If
for each e in LqGb
xxx....
next
linq 在 for each 枚举元素时才会 执行上面的筛选语句,因此 where 可以 叠加使用