0
 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 条件查询返回结果以及邮箱名称等于“test@hetest.com”的条目时。

var result = iquery .Select(var => new MailBoxReconEntry
                                  {
                                      AccountStatus = var.AccountStatus, LatestEndDate = var.LatestEndDate, 
                                      MailboxStatus = var.MailboxStatus,
                                      OrgName = var.OrgName
                                  }).ToList();
4

1 回答 1

2

where 语句不应该出现在主 LINQ 请求中吗?

LINQ 请求被转换为 SQL,因此 where 语句应该是 LINQ 查询的一部分,而不是之后

所以

 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

有点粗糙,但应该给你的想法?

于 2013-10-03T21:58:59.273 回答