EntityQuery 加载帮助

发布于 2024-11-07 06:00:00 字数 1234 浏览 3 评论 0原文

我有以下代码:

        EntityQuery<Web.Ticket> query =
               from t in ticketClass.getQuery()
               where t.showId == selectedShowId
               select t;

        LoadOperation<Web.Ticket> loadTic = ticketClass.loadTicketsQuery(query);
        loadTic.Completed += (s, a) =>
        {
            List<int> takenSeats = new List<int>();
            foreach (Web.Ticket ticket in ticketClass.getContext())
            {
                takenSeats.Add((int)ticket.seatId);
                MessageBox.Show(ticket.seatId.ToString());
            }
        };

getQuery:

public EntityQuery<Web.Ticket> getQuery()
        {
            return _ticketContext.GetTicketsQuery();
        }

loadTicketsQuery:

public LoadOperation<Web.Ticket> loadTicketsQuery(EntityQuery<Web.Ticket> query)
        {
            return _ticketContext.Load(query);
        }

getContext:

public EntitySet getContext()
        {
            return _ticketContext.Tickets;
        }

我面临的问题是 MessageBox 未加载,我已确保应该捕获两条数据,但它永远不会到达那里。谁能帮我解释为什么我的代码不起作用。

谢谢。

I have the following code:

        EntityQuery<Web.Ticket> query =
               from t in ticketClass.getQuery()
               where t.showId == selectedShowId
               select t;

        LoadOperation<Web.Ticket> loadTic = ticketClass.loadTicketsQuery(query);
        loadTic.Completed += (s, a) =>
        {
            List<int> takenSeats = new List<int>();
            foreach (Web.Ticket ticket in ticketClass.getContext())
            {
                takenSeats.Add((int)ticket.seatId);
                MessageBox.Show(ticket.seatId.ToString());
            }
        };

getQuery:

public EntityQuery<Web.Ticket> getQuery()
        {
            return _ticketContext.GetTicketsQuery();
        }

loadTicketsQuery:

public LoadOperation<Web.Ticket> loadTicketsQuery(EntityQuery<Web.Ticket> query)
        {
            return _ticketContext.Load(query);
        }

getContext:

public EntitySet getContext()
        {
            return _ticketContext.Tickets;
        }

The problem I am facing is that the MessageBox does not load, I have made sure there are two pieces of data that should be caught it never gets there. Can anyone help me on why my code isn't working.

Thanks.

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

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

发布评论

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

评论(1

时光瘦了 2024-11-14 06:00:00

试试这个

loadTic.Completed += (s, a) =>
    {
        List<int> takenSeats = new List<int>();
        foreach (Web.Ticket ticket in  ((LoadOperation<Web.Ticket>)s).Entities.ToList())
        {
            takenSeats.Add((int)ticket.seatId);
            MessageBox.Show(ticket.seatId.ToString());
        }
    };

Try this

loadTic.Completed += (s, a) =>
    {
        List<int> takenSeats = new List<int>();
        foreach (Web.Ticket ticket in  ((LoadOperation<Web.Ticket>)s).Entities.ToList())
        {
            takenSeats.Add((int)ticket.seatId);
            MessageBox.Show(ticket.seatId.ToString());
        }
    };
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文