Les données de l'échantillon que vous avez fournies ne renvoyaient pas de valeur de toute façon, car ils clientId et EngagementId ont tous des valeurs.
Je divise le LINQ en deux listes. Je n'ai pas encore testé ou optimisé cela, mais c'est peut-être ce que vous cherchez pour au moins vous aider à démarrer.
Voici ma tentative:
Public Class DBObject
Public Sub New(ByVal cId As Integer, _
ByVal eId As Integer, _
ByVal enabled As Boolean, _
ByRef desc As String)
_clientId = cId
_engagementId = eId
_enabled = enabled
_description = desc
End Sub
Private _clientId As Integer
Public Property ClientId() As Integer
Get
Return _clientId
End Get
Set(ByVal value As Integer)
_clientId = value
End Set
End Property
Private _engagementId As Integer
Public Property EngagementId() As Integer
Get
Return _engagementId
End Get
Set(ByVal value As Integer)
_engagementId = value
End Set
End Property
Private _enabled As Boolean
Public Property Enabled() As Boolean
Get
Return _enabled
End Get
Set(ByVal value As Boolean)
_enabled = value
End Set
End Property
Private _description As String
Public Property Description() As String
Get
Return _description
End Get
Set(ByVal value As String)
_description = value
End Set
End Property
End Class
Dim DB1 As New List(Of DBObject)
Dim DB2 As New List(Of DBObject)
DB1.Add(New DBObject(600, 10, True, "Company1"))
DB1.Add(New DBObject(600, 20, False, "Company2"))
DB1.Add(New DBObject(700, 10, True, "Company3"))
DB2.Add(New DBObject(600, 5, True, "Company1"))
DB2.Add(New DBObject(600, 10, False, "Company2"))
DB2.Add(New DBObject(500, 30, True, "Company3"))
Dim list1 As List(Of DBObject) = (From obj1 As DBObject In DB1 _
Join obj2 As DBObject In DB2 _
On obj1.ClientId Equals obj2.ClientId _
And obj1.EngagementId Equals obj2.EngagementId _
Where obj2.ClientId = Nothing _
And obj2.EngagementId = Nothing _
Select obj1).ToList
Dim list2 As List(Of DBObject) = (From obj3 As DBObject In list1 _
From obj4 As DBObject In DB2 _
Where obj3.ClientId = obj4.ClientId _
Select obj3).ToList
' list2 would have the results you desire
s'il vous plaît don N'incluez pas de balises comme "VB.NET" dans le titre. Laissez-les simplement dans les tags. –