2017-05-31 5 views
0

Je cette requête:LINQ orderby même champ de valeur différente

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 
       }; 

Ce que je veux obtenir est maintenant de commander les articles par un champ, LoanStatusId commençant par des prêts qui n'ont pas LoanStatusId de 4 ou 8

Une idée de comment je peux y parvenir? Merci, Laziale

+0

Voulez-vous que 4-8 soit en bas non ordonné ou vous ne voulez pas du tout? –

+0

@FilipCordas au fond thx – Laziale

Répondre

0

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 
       };