How can i write a inner join query using linq

2019-06-11 14:07发布

I have write a inner join query. In SQL Server it is working fine, but I want to write this query using Linq-to-SQL. Can anybody help me please?

Here is my query in SQL Server:

select db.Firstname, db.lastname, lo.BiPayAmt, lo.Loan_ID, sc.Pmt_Id,
    sc.Terms, sc.pmt_dates, sc.LoanId
from dbo.Clients db
inner join dbo.Loans lo on db.Client_ID = lo.Client_ID
inner join dbo.SchedulePayments sc on lo.Loan_ID = sc.LoanId

1条回答
对你真心纯属浪费
2楼-- · 2019-06-11 14:48

Roughly this:

from db in dbo.Clients
join lo in dbo.Loans on db.Client_ID equals lo.Client_ID
join sc in dbo.SchedulePayments on lo.Loan_ID equals sc.LoanId
select new
{
    db.Firstname,
    db.lastname,
    lo.BiPayAmt,
    lo.Loan_ID,
    sc.Pmt_Id,
    sc.Terms,
    sc.pmt_dates,
    sc.LoanId
}
查看更多
登录 后发表回答