Public Class ListComparison
Public Function CompareTwoLists(Of T1, T2, TDuplicate As DuplicateExpression)(list1 As IEnumerable(Of T1), list2 As IEnumerable(Of T2), compareValue As Func(Of T1, T2, Boolean), DuplicateExpression As List(Of TDuplicate)) As Boolean
Return list1.[Select](Function(item1) list2.Any(Function(item2) compareValue(item1, item2))).All(Function(search) search) AndAlso list2.[Select](Function(item2) list1.Any(Function(item1) compareValue(item1, item2))).All(Function(search) search)
End Function
Public Function CompareLists(Of T1, TDuplicate As DuplicateExpression)(list1 As IEnumerable(Of T1), list2 As IEnumerable(Of T1), DuplicateExpression As List(Of TDuplicate)) As String
Dim InvalidDuplicateExpression As List(Of TDuplicate) = New ExtensionHelper().ValidateColumnInList(Of T1, TDuplicate)(DuplicateExpression)
Dim js As New System.Web.Script.Serialization.JavaScriptSerializer()
If InvalidDuplicateExpression.Count() <= 0 Then
Dim Fields As String() = DuplicateExpression.[Select](Function(x) x.ExpressionName).ToArray()
Dim JoinExp = list1.Join(list2, Fields)
Dim IsDuplicate As Boolean = True
IsDuplicate = CompareTwoLists(list1, list2, Function(listx1, listx2) JoinExp.Any(), DuplicateExpression)
If IsDuplicate Then
Return js.Serialize(New With { _
Key .IsValidateExpression = True, _
Key .IsValidateDuplicate = IsDuplicate, _
Key .Message = "Duplicate Items in the List" _
})
Else
Return js.Serialize(New With { _
Key .IsValidateExpression = True, _
Key .IsValidateDuplicate = IsDuplicate _
})
End If
Else
Return js.Serialize(New With { _
Key .IsValidateExpression = False, _
Key .InvalidExpressions = InvalidDuplicateExpression, _
Key .Message = "Duplicate Expression is not Invalid" _
})
End If
End Function
Public Shared Function CreateSelector(Of T)(PropertyNames As IEnumerable(Of String)) As Func(Of T, Object)
Dim SourceType = GetType(T)
Dim Parameter = Expression.Parameter(SourceType, "e")
Dim Properties = PropertyNames.[Select](Function(Name) Expression.PropertyOrField(Parameter, Name)).ToArray()
Dim Selector = Expression.Lambda(Of Func(Of T, Object))(Expression.[Call](GetType(Tuple), "Create", Properties.[Select](Function(p) p.Type).ToArray(), Properties), Parameter)
Return Selector.Compile()
End Function
Public Shared Function Join(Of T)(Left As IEnumerable(Of T), Right As IEnumerable(Of T), PropertyNames As IEnumerable(Of String)) As IEnumerable(Of Tuple(Of T, T))
Dim KeySelector = CreateSelector(Of T)(PropertyNames)
Return Left.Join(Right, KeySelector, KeySelector, AddressOf Tuple.Create)
End Function
End Class
Wenn ich diesen Code kompiliere bekomme ich folgenden Fehler.VB.net Linq Join Ausdruck Fehler
Fehler 15 Überladungsauflösung ist fehlgeschlagen, weil kein zugängliches 'Join' diese Anzahl von Argumenten akzeptiert.
Dim JoinExp = list1.Join(list2, Fields)
Der Fehler ist auf dem oberen Zeile. Dies wird hauptsächlich für den Listenvergleich mit dynamischen Spalteneigenschaften verwendet. Dieser Code funktioniert ordnungsgemäß in C# .net. Wenn ich C# .net Code zu Vb.net umwandle; diesen Fehler bekommen. Wie löst man das in Vb.net?