4
使用LINQ搜索對象的列表中的對象名單上有2班在VB.net
Public Class Shipper
Public Property ShipperID As Long
Public Property CreateDate As DateTime
Public Property ShipperCode As String
Public Property ShipperName As String
Public Property ShippingMethods As List(Of ShippingMethod)
Public Class ShippingMethod
Public Property ShippingMethodID As Long
Public Property ShipperID As Long
Public Property CreateDate As DateTime
Public Property ShipppingMethod As String
Public Property ShipppingMethodCode As String
我試圖尋找貨主的列表,其中shippercode是空白,ShipperName不是空白的 - 我得到的通過
Dim oListShipper As List(Of Shipper) = GetAllShippers()
Dim oListShipperRet As List(Of Shipper) = _
oListShipper.FindAll(Function(c) (c.ShipperCode = "" And _
c.ShipperName <> ""))
現在我該怎樣讓所有的貨主那裏ShippingMethod.ShipppingMethodCode = '' 和ShippingMethod.ShipppingMethod <>'
我試過
oListShipper.FindAll(Function(c) (c.ShipperCode = "" And _
c.ShipperName <> "")) Or _
(c.ShippingMethods.FindAll(Function(d) d.ShipppingMethodCode = "" And _
d.ShipppingMethod <> "").Count > 1)))
但沒有工作。任何想法 ?
感謝 Jothish
謝謝你的一些改變。不得不改變。因爲我需要一個列表,並且還將&&更改爲'OR',因此我需要一個列表。 – JoR 2010-12-22 18:57:13