使用ObjectQuery将SubQuery子化到本地列表

时间:2011-04-12 21:08:23

标签: vb.net linq entity-framework

我需要查找状态在Integer的本地列表中的所有记录。 在SQL中我会做

Where Status in (select i from my list)

但我无法想象如何在Linq中实现它。

ListData = New IssueTrackerEntities2()

Dim queryString As String = "SELECT VALUE CallList FROM IssueTrackerEntities2.CallList AS CallList"

    Dim Status As New List(Of Integer)

    queryString += "Where CallList.AssignToValue = @AssignTo"

    Dim TicketQuerys As New ObjectQuery(Of CallList)(queryString, ListData)

    TicketQuerys.Parameters.Add(New ObjectParameter("AssignTo", AssignToFilter.EditValue))

1 个答案:

答案 0 :(得分:1)

包含扩展方法是您要搜索的运算符。

int[] localList = {1, 2, 3, 4};
var allItems = GetAllItems();
var filteredItems = from i in allItems where localList.Contains(i.Status) select i;