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
开发者_如何学C 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
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.
精彩评论