0
我想改变Where子句将应用在哪个字段取决于函数接收的布尔值。到目前为止,我有这样的:LINQ where子句与不同的字段
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
但我不断收到:
Conversion from string "someString" to type 'Integer' is not valid.
..当我设置bValueIsString为true。
-
我知道ScottGu的动态LINQ库,但如果可能的话,我宁愿不使用任何外部元件..
感谢它工作:) – jplanglais 2013-04-23 14:34:56