J
john
I'm trying to build a LINQ expression that will use a dynamic construction
of a LIKE statement in the WHERE clause, it would look something like this
in SQL:
WHERE TaskGroup Like "*00*" OR TaskGroup Like "*20*"
It would be many variations on the above.
I know how use the LIKE clause in LINQ but not in this context, here is an
attempt that did not work, I also tried building it into a variable that
looked like the LINQ LIKE clause if I were to type it out (WHERE filterExp)
but it did not work either.
Thanks for any input
filterExp = ""
i = InStr(1, strFilter, ":")
Do Until i = 0
filterExp = filterExp & """Like *" & Mid(strFilter, i - 2, 2) &
"*"""
i = InStr(i + 1, strFilter, ":")
If i <> 0 Then
filterExp = filterExp + ", "
End If
Loop
Dim grp As String() = {filterExp}
Dim dbTask As New DataTaskDataContext
Dim taskTbl = From tas In dbTask.tblTasks _
Where grp.Contains(tas.TaskGroup) _
Select tas
of a LIKE statement in the WHERE clause, it would look something like this
in SQL:
WHERE TaskGroup Like "*00*" OR TaskGroup Like "*20*"
It would be many variations on the above.
I know how use the LIKE clause in LINQ but not in this context, here is an
attempt that did not work, I also tried building it into a variable that
looked like the LINQ LIKE clause if I were to type it out (WHERE filterExp)
but it did not work either.
Thanks for any input
filterExp = ""
i = InStr(1, strFilter, ":")
Do Until i = 0
filterExp = filterExp & """Like *" & Mid(strFilter, i - 2, 2) &
"*"""
i = InStr(i + 1, strFilter, ":")
If i <> 0 Then
filterExp = filterExp + ", "
End If
Loop
Dim grp As String() = {filterExp}
Dim dbTask As New DataTaskDataContext
Dim taskTbl = From tas In dbTask.tblTasks _
Where grp.Contains(tas.TaskGroup) _
Select tas