来自对象的LINQ Left Join

时间:2017-01-12 20:03:56

标签: entity-framework linq left-join entity-framework-core

我有一个linq查询,当我连接两个表时工作正常,但当我包含另一个表时,它不返回数据。请帮我弄清楚我做错了什么。

First Linq返回数据:

var q = (from c in _context.Complaint
        join cl in _context.Checklist on c.COMP_ID equals cl.COMP_ID into clleft
        from cls in clleft.DefaultIfEmpty()
        orderby c.timestamp descending
        select new
         {
          FileNum = c.FileNum
         }).AsQueryable().Distinct();

         return q;

当我添加此表时,没有数据返回

var q = (from c in _context.Complaint
        join cl in _context.Checklist on c.COMP_ID equals cl.COMP_ID into clleft
        from cls in clleft.DefaultIfEmpty()
        join oim in _context.OIM_EMPLOYEE on cls.MonitorEnteredEmpID equals oim.EmpID into oimleft
        from oims in oimleft.DefaultIfEmpty()
        orderby c.timestamp descending
        select new
              {FileNum = c.FileNum
              }).AsQueryable().Distinct();

        return q;

0 个答案:

没有答案