I have a list of persons "Gezinslijst" and the head of the family "Klanten". I want to fill a list with all persons and get a list of the family with a list property containing his family members.
This works, but takes 30-60 seconds to load. I know it's because I have to filter 2600 times to get the list, but I don't know how to write it more efficiently.
Private Sub Initialize()
Dim Gezinslijst As List(Of GetClientsGezin_Result) = New List(Of GetClientsGezin_Result)
Gezinslijst = (From k In db.GetClientsGezin() Select k).ToList()
Dim Klanten As List(Of Klanten) = New List(Of Klanten)
Klanten = (From k In db.GetClients() Select New Klanten With {
.Naam = k.Naam,
.Status = k.Status,
.Prefix = k.Prefix,
.Rijksregisternr = k.Rijksregisternr,
.Saldo = k.Saldo,
.SubCategorie = k.SubCategorie,
.Straat = k.Straat,
.Huisnr = k.Huisnr,
.Busnr = k.Busnr,
.Postcode = k.Postcode,
.Plaats = k.Plaats,
.Land = k.Land,
.ID_Key = k.ID_Key,
.Gezinsleden = Gezinslijst.Where(Function(x) x.ID_DiftarClient = k.ID_Key).ToList()
}).ToList()
End Sub
Thanks in advance for any help