How to pass a LINQ query to a Sub and filter it?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • axplains
    New Member
    • Feb 2010
    • 5

    How to pass a LINQ query to a Sub and filter it?

    Hello, I have a LINQ query:
    Code:
    Dim Db = New MyDataContext
    Dim Qry = From cust in Db.Customers
         Select cust.ID, cust.Name
    And I want to pass it to a function to filter it, like this:
    Code:
    FilterQuery(Qry, ID)
    ...
    
    Sub FilterQuery(ByVal MyQry as iQueryable, MyField as ???)
      MyQry = MyQry.Where(MyField = "somevalue")
    End Sub
    How can I pass "MyField" to the Sub and make the LINQ "Where" clause work?
    Is there any workaround?
    Thank you.
Working...