(I'm new in VB.Net) I have these three classes:

Public Class Classe_PIVA_Cond

Public Property my_codFiscale As String
Public Property my_presenzaDuplicati As Boolean
Public Property my_listaCondominii As New List(Of Classe_Condominio)

Public Sub New()
End Sub


Public Sub New(codFiscale As String, presenzaDuplicati As Boolean, listaCondominii As List(Of Classe_Condominio))
    Me.my_codFiscale = codFiscale
    Me.my_presenzaDuplicati = presenzaDuplicati
    Me.my_listaCondominii = listaCondominii
End Sub

End Class

'==================================

Public Class Classe_Condominio

Public Property my_Studio As New Classe_Studio
Public Property my_Amministratore As New Classe_Amministratore
Public Property my_codCondominio As String
Public Property my_indirizzo As String
Public Property my_comune As String
Public Property my_cap As String
Public Property my_provincia As String
Public Property my_codFiscale As String

Public Sub New()
End Sub

Public Sub New(studio As Classe_Studio, amministratore As Classe_Amministratore, codCondominio As String, indirizzo As String, comune As String, cap As String, provincia As String, codFiscale As String)
    Me.my_Studio = studio
    Me.my_Amministratore = amministratore
    Me.my_codCondominio = codCondominio
    Me.my_indirizzo = indirizzo
    Me.my_comune = comune
    Me.my_cap = cap
    Me.my_provincia = provincia
    Me.my_codFiscale = codFiscale
End Sub

End Class

'==================================

Public Class Classe_Studio

Public Property my_codice As String
Public Property my_ragioneSociale As String
Public Property my_pIvaCodFisc As String

Public Sub New()
End Sub

Public Sub New(codice As String, ragioneSociale As String, pIvaCodFisc As String)
    Me.my_codice = codice
    Me.my_ragioneSociale = ragioneSociale
    Me.my_pIvaCodFisc = pIvaCodFisc
End Sub

End Clas

I would try to return a List of distinct Classe_Studio.my_codice in a List(Of Classe_PIVA_Cond). Any suggestion?

1 Answers

0
Matt.G On Best Solutions

Try

    Dim my_codiceDistinctList = Classe_PIVA_CondList
                                        .SelectMany(Function(x) x.my_listaCondominii)
                                        .Select(Function(y) y.my_Studio.my_codice)
                                        .Distinct()
                                        .ToList()