var iquery = (from m in dc.m_MAILBOXes
join o in dc.o_ORGANIZATIONs on m.m_o_ID equals o.o_ID
join h in dc.h_HOSTED_EXCHANGE_ACCOUNTs on o.o_ID equals h.h_o_ID
join my in dc.my_MAILBOX_SUMMARies on m.m_ID equals my.my_m_ID
orderby my.my_START_DATE descending
select new { MailboxName = m.m_NAME, OrgName = o.o_NAME, MailboxStatus = m.m_STATUS,
LatestEndDate = my.my_END_DATE, AccountStatus = h.h_STATUS }).Where(r => r.MailboxName == "test@hetest.com"));
这是我使用的查询以及where条件并且不返回任何结果。 我完全不确定我哪里出错了。当我删除where条件查询返回结果以及mailboxname等于“test@hetest.com”的条目时。
var result = iquery .Select(var => new MailBoxReconEntry
{
AccountStatus = var.AccountStatus, LatestEndDate = var.LatestEndDate,
MailboxStatus = var.MailboxStatus,
OrgName = var.OrgName
}).ToList();
答案 0 :(得分:2)
不应该在主LINQ请求中使用where语句,
LINQ请求转换为SQL,因此where语句应该是LINQ Query的一部分而不是
之后所以
var iquery = (from m in dc.m_MAILBOXes
join o in dc.o_ORGANIZATIONs on m.m_o_ID equals o.o_ID
join h in dc.h_HOSTED_EXCHANGE_ACCOUNTs on o.o_ID equals h.h_o_ID
join my in dc.my_MAILBOX_SUMMARies on m.m_ID equals my.my_m_ID
where m.MailboxName == "test@hetest.com"
orderby my.my_START_DATE descending
有点粗糙,但应该给你一个想法?