Imports System.Text
Public Class Form1
Private _custs As CustomerList
Public Property Custs() As CustomerList
Get
Return _custs
End Get
Set(ByVal value As CustomerList)
_custs = value
End Set
End Property
Private Sub Command1_Click() Handles Button1.Click
Dim res = From c In Custs _
From f In c.Funds _
Where c.Name = "Shell" _
Select f
Dim s As New StringBuilder
For Each item In res
s.AppendLine(item.ID.ToString)
Next
MessageBox.Show(s.ToString)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Custs = New CustomerList
custs.Add(New Customer With {.Name = "Shell"})
custs(0).Funds = New FundList
custs(0).Funds.Add(New Fund With {.ID = 1})
custs(0).Funds.Add(New Fund With {.ID = 2})
custs(0).Funds.Add(New Fund With {.ID = 3})
custs.Add(New Customer With {.Name = "Toyota"})
Custs(1).Funds = New FundList
Custs(1).Funds.Add(New Fund With {.ID = 4})
Custs(1).Funds.Add(New Fund With {.ID = 5})
End Sub
End Class
Public Class Customer
Private _name As String
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Private _funds As FundList
Public Property Funds() As FundList
Get
Return _funds
End Get
Set(ByVal value As FundList)
_funds = value
End Set
End Property
End Class
Public Class CustomerList
Inherits List(Of Customer)
End Class
Public Class Fund
Private _id As Integer
Public Property ID() As Integer
Get
Return _id
End Get
Set(ByVal value As Integer)
_id = value
End Set
End Property
End Class
Public Class FundList
Inherits List(Of Fund)
End Class
|