Hi John,
As for LIKE syntax query, I've found some similar threads discussing on
this, and some of them're using a string comparing approach to do the LIKE
query in LINQ:
http://blogs.microsoft.co.il/blogs/b...linq-to-sql-li
ke-operator.aspx
http://forums.microsoft.com/MSDN/Sho...70290&SiteID=1
You may have a look to see whether it helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "john" <>
>Subject: Dynamic Like clause in LINQ How?
>Date: Sat, 2 Feb 2008 07:13:01 -0500
>
>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
>
>
>
>