这是我的清单
locList.Add(New Location() With {.ID = "001", .Name = "KTYM"})
' 2 products
prdList.Add(New Product() With {.ID = "001", .Locations = locList, .Name = "Boost"})
prdList.Add(New Product() With {.ID = "003", .Locations = locList, .Name = "Pears"})
locList = New List(Of Location)
prdList = New List(Of Product)
locList.Add(New Location() With {.ID = "002", .Name = "TVM"})
' 3 products
prdList.Add(New Product() With {.ID = "002", .Locations = locList, .Name = "Horlicks"})
prdList.Add(New Product() With {.ID = "003", .Locations = locList, .Name = "Pears"})
prdList.Add(New Product() With {.ID = "004", .Locations = locList, .Name = "Colgate"})
locList = New List(Of Location)
prdList = New List(Of Product)
locList.Add(New Location() With {.ID = "003", .Name = "KNR"})
' 4 prod
prdList.Add(New Product() With {.ID = "B05", .Locations = locList, .Name = "CloseUP"})
prdList.Add(New Product() With {.ID = "003", .Locations = locList, .Name = "Pears"})
prdList.Add(New Product() With {.ID = "016", .Locations = locList, .Name = "Maggi"})
prdList.Add(New Product() With {.ID = "A07", .Locations = locList, .Name = "Dairy Milk"})
每个产品都有一个位置。我想从给定位置的列表中选择所有产品。我怎样才能实现它?我正在为 CE 设备使用 .net 3.5。谢谢你的帮助。
编辑
Dim prd = From p As Product In prdList _
From loc As Location In p.Locations _
Where loc.ID = "001" _
Select p
这里 prd.Count 它返回零。