How can i write a inner join query using linq
I have write a inner join query. In SQL Server it is working fine, but I want to write this query usin开发者_如何学Pythong 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
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
}
精彩评论