I'm trying to change on which field the Where clause will be applied depending on a Boolean value received by the function. So far I have this:
Public Function SomeFunction(ByVal value As String, Optional bValueIsString As Boolean = False) As JsonResult
...
Dim q = (From t In table
Where If(bValueIsString, t.Desc=value, t.Id=value)
Select New With {.Id,
.LongDescription,
.Desc)})
...
End Function
But I keep receiving:
Conversion from string "someString" to type 'Integer' is not valid.
.. when I set bValueIsString to true.
-
I know about ScottGu's Dynamic LINQ Library, but I would rather not use any external component if possible..