Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I´m somewhat new to VB.Net and have a problem here:


I have two classes: Products and Components

Products
productnumber
mycomponentlist List(of Components)
...
Components
componentnumber
...

I now want to search for a componentnumber in

myProductlist List(of Products) to get all Products with this component.


How can I do this without using several For-Loops?

What i found was something like this:
Dim results As List(Of Components)
results = mycomponentlist.FindAll(Function(column) column.componentnumber= "123")
Posted
Updated 27-Nov-14 21:27pm
v2

Try:
VB
Dim results = myProductList.Where(Function(pp) pp.MyComponentList.Where(Function(cc) cc.ComponentNumber = 123).Count() <> 0)
 
Share this answer
 
try use this condition
if(ListProducts.Intersect(sublist).Count > 0)
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900