Linq orderby 同字段不同值

Linq orderby same field different value

我有这个查询:

investorData = from investor in db.Investors
               join loanapp in db.LoanApplications on investor.FundID equals loanapp.FundID into loanAppData
               from lapp in loanAppData.DefaultIfEmpty()
               join fundreport in db.FundReportLoanDatas on lapp.LoanId equals fundreport.LoanId into fundReportData
               from freport in fundReportData.DefaultIfEmpty()
               where investor.FundID == fundID
               orderby lapp.LoanId descending
               select new InvestorPortfolioVM()
               {
                   InvestorId = investor.InvestorID,
                   CurrentLTV = freport.CurrentLTV == null ? 0.0 : freport.CurrentLTV,
                   LoanId = lapp.LoanId,
                   SegLTV = freport.SegLTV == string.Empty ? "" : freport.SegLTV,
                   BorrowerName = lapp.BorrowerName,
                   LoanStatusId = lapp.LoanStatusId
               };

我现在想要实现的是按一个字段排序项目,LoanStatusId 以贷款开头,其 LoanStatusId 不是 4 或 8。

知道如何实现吗?

我想这会做你想要的。

investorData = from investor in db.Investors
               join loanapp in db.LoanApplications on investor.FundID equals loanapp.FundID into loanAppData
               from lapp in loanAppData.DefaultIfEmpty()
               join fundreport in db.FundReportLoanDatas on lapp.LoanId equals fundreport.LoanId into fundReportData
               from freport in fundReportData.DefaultIfEmpty()
               where investor.FundID == fundID
               orderby (lapp.LoanId >= 4 &&  lapp.LoanId <= 8) ? 1 : 0
               select new InvestorPortfolioVM()
               {
                   InvestorId = investor.InvestorID,
                   CurrentLTV = freport.CurrentLTV == null ? 0.0 : freport.CurrentLTV,
                   LoanId = lapp.LoanId,
                   SegLTV = freport.SegLTV == string.Empty ? "" : freport.SegLTV,
                   BorrowerName = lapp.BorrowerName,
                   LoanStatusId = lapp.LoanStatusId
               };