如何通过将linq中的多个表组合到实体来使用orderby

时间:2014-01-29 09:37:28

标签: c# linq linq-to-sql linq-to-entities

我的表是,

  1. 工作
  2. Emp.Reg.Details
  3. Emp.Plans
  4. Alertsdone
  5. CntactsViewed
  6. 这些是表格。通常是作业表中列出的作业列表..我在所有其他表格中进行比较..

    我的linq查询

    public IQueryable<Job> GetJobs()
    {
        return (from job in _db.Jobs
                from ep in _db.Emp.Plans
                from al in _db.Alertsdone
                from cvc in _db.CntactsViewed
    
                join emps in _db.Emp.Reg.Details on job.OrganizationId equals emps.EmployerId into e
                join alr in _db.Alertsdone on ep.Alerts equals alr.AlertsSent
                join cv in _db.CntactsViewedon ep.Resumes equals cv.ContactsViewed
                from emp in e.DefaultIfEmpty()
    
                orderby job.OrganizationId != -1 descending, job.OrganizationId != null descending
                orderby job.OrganizationId != -1 descending, emp.EmployerId == job.OrganizationId && alr.alertssent ==ep.alerts descending, job.CreatedDate descending
                select job);
    }
    

    如果我这样给它显示空白页面..我正在尝试如果上述条件不存在意味着它应该订购其他选项,如orderby job.OrganizationId != -1 descending, job.OrganizationId != null descending ..而且我也放from emp in e.DefaultIfEmpty() ...但我错过了哪里?请帮帮我......

0 个答案:

没有答案