LINQ

2017-05-31 8 views
0

私はこのクエリを持っている:LINQ

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

私は今達成したいどのような1つのフィールドでアイテムを注文することです、LoanStatusId 4または8のLoanStatusIdを持っていないローンで始まります。

どのように私はそれを達成することができますか?

おかげで、Laziale

+0

4-8を順序無しの底にしたいのですか、まったく欲しくないのですか? –

+0

@FilipCordasの下のthx – Laziale

答えて

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