У меня есть оператор if, который возвращает результат в виде AsQueryable анонимному типу:
If (signature = "") Then
testResults = (From TRTable In context.TestResults
Where ((TRTable.Art_no = currentProduct) And (TRTable.Server_time > startDate) And (TRTable.Server_time < endDate))
Select TRTable.Art_no, TRTable.Failed, TRTable.Retested).AsQueryable
ElseIf (signInfo = "out") Then
testResults = (From TRTable In context.TestResults
Where ((TRTable.Art_no = currentProduct) And (TRTable.Server_time > startDate) And (TRTable.Server_time < endDate) And TRTable.Sign <> signature)
Select TRTable.Art_no, TRTable.Failed, TRTable.Retested).AsQueryable
Else
testResults = (From TRTable In context.TestResults
Where ((TRTable.Art_no = currentProduct) And (TRTable.Server_time > startDate) And (TRTable.Server_time < endDate) And TRTable.Sign = signature)
Select TRTable.Art_no, TRTable.Failed, TRTable.Retested).AsQueryable
End If
А потом, когда я делаю
StatisticsModel.Passed = testResults.Where(Function(p) p.Failed = 0).Count
, я получаю
Method invocation failed because 'Public Function Where(predicate As String, ParamArray parameters As System.Data.Objects.ObjectParameter()) As System.Data.Objects.ObjectQuery`1[[VB$AnonymousType_3`3[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Nullable`1[[System.Decimal, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Nullable(Of VB$AnonymousType_3(Of String,Nullable(Of Decimal),Nullable(Of Decimal)))' cannot be called with these arguments:
Argument matching parameter 'predicate' cannot convert from 'VB$AnonymousDelegate_1(Of Object,Object)' to 'String'.
Извините за длинную строку текста, но я не могу понять, почему он не работает, он работал без оператора if, но мне нужна эта функциональность.Спасибо:)