0

How would I get something like this to work so that I can dynamically alter the where-clause in this linq to sql query?

Dim AccountID = 1234

Dim AccountList

Select Case Types
    Case 1
        AccountList = (from a in dc.Accounts where a.ID = AccountID)
    Case 2
        AccountList = (from a in dc.Accounts where a.ID = AccountID And a.ParentID = AccountID)
    Case Else
        AccountList = (from a in dc.Accounts)
End Select

Return From p in dc.Products where AccountList.Contains(p.Order.Transaction.AccountID)

With the above code I get this error:

Late binding operations cannot be converted to an expression tree

1 Answer 1

3

It sounds like you've either not got Option Strict on. Put it on, and specify the type of AccountList as IQueryable(Of Account). Then you won't be using late binding, and all should be well.

Sign up to request clarification or add additional context in comments.

1 Comment

The AccountList is just a list of strings actually so making it IQueryable(of String) did the trick - thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.