【发布时间】:2011-04-12 06:59:44
【问题描述】:
我怎样才能让这样的事情起作用,以便我可以动态地改变这个 linq to sql 查询中的 where 子句?
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)
使用上面的代码我得到这个错误:
后期绑定操作无法转换为表达式树
【问题讨论】:
标签: vb.net linq linq-to-sql dynamic where-clause