如何使用linq查询降序使用多个Order显示结果

时间:2015-02-05 08:57:11

标签: c# sql linq

我有3个标准。我想订购这3种类型。

  1. 谁支付了主用户

  2. 谁更新了他们的帖子最新日期

  3. 谁支付了子主用户

  4. 哪一个正在计算它将进入前15名工作。

    我的代码在这里:

    var orderMaster= _vasRepository.GetOrderDetails()
                             .Where(od => od.OrderMaster.OrganizationId != null &&
                                    od.OrderId == od.OrderMaster.OrderId && 
                                    od.OrderMaster.PaymentStatus == true && 
                                    od.ValidityTill.Value >= currentdate)
                             .OrderByDescending(od => od.ValidityTill)
                             .Select(ord => ord.OrderMaster.Id.Value);
    
    var updatedVacancyList = _repository.GetJobs()
                                        .Where(c => c.UpdatedDate != null && 
                                               updateFresh <= c.UpdatedDate)
                                        .Select(c => c.Id);
    
    var orderLatestUser = _vasRepository.GetOrderDetails()
                                        .Where(od => od.OrderMaster.UserId != null && 
                                               od.OrderMaster.PaymentStatus == true && 
                                               freshUser <= od.ActivationDate && 
                                               od.ValidityTill.Value >= currentdate)
                                        .Select(c => c.OrderMaster.User.Id);
    

    然后我检查那些然后分配给

    的计数
    List<int> lstMasterId = orderOrganization.ToList();
    List<int>lstUpdatedJobsListId = updatedVacancyList.ToList();
    List<int>lstUserListId= orderLatestUser.ToList();
    

    我在这里使用查询

    订购列表
    Func<IQueryable<Job>, IOrderedQueryable<Job>> orderingFunc = query => 
    {
        if (orderMaster.Count() > 0)
            return query.OrderByDescending(rslt => 
                lstOrganizationId.Contains(rslt.OrganizationId))                
                  .ThenByDescending(rslt=>lstUserListId.Contains(rslt.User.Id))
                  .ThenByDescending(rslt => lstUpdatedJobsListId.Contains(rslt.Id))
                  .ThenByDescending(rslt => rslt.CreatedDate);
    
        else
            return query.OrderByDescending(rslt => rslt.CreatedDate);
    };
    
                jobs = orderingFunc(jobs);
            }
    

    我想在结果的顶部显示lstUserListId ..怎么做?

0 个答案:

没有答案