我有以下代码:
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());
}
};
获取查询:
public EntityQuery<Web.Ticket> getQuery()
{
return _ticketContext.GetTicketsQuery();
}
loadTickets查询:
public LoadOperation<Web.Ticket> loadTicketsQuery(EntityQuery<Web.Ticket> query)
{
return _ticketContext.Load(query);
}
获取上下文:
public EntitySet getContext()
{
return _ticketContext.Tickets;
}
我面临的问题是 MessageBox 没有加载,我确保有两条数据应该被捕获它永远不会到达那里。谁能帮我解释为什么我的代码不起作用。
谢谢。