使用 ObjectQuery 对本地列表进行子查询

发布于 2024-11-01 01:44:35 字数 575 浏览 1 评论 0原文

我需要查找状态位于整数本地列表中的所有记录。 在 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))

I need to find all records where the status is in the local list of Integer's.
In SQL I would do

Where Status in (select i from my list)

But I can't figure how to make it happen in 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))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅听莫相离 2024-11-08 01:44:35

Contains 扩展方法是您正在搜索的运算符。

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

The Contains extension method is the operator you're searching for.

int[] localList = {1, 2, 3, 4};
var allItems = GetAllItems();
var filteredItems = from i in allItems where localList.Contains(i.Status) select i;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文