2011-09-15 77 views
0

我已經編寫了內部連接查詢。在SQL Server中它工作正常,但我想用Linq-to-SQL編寫這個查詢。有人可以幫我嗎?我如何使用linq編寫內部連接查詢

這是我在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 
+0

好吧,我得到了解決,我有我自己寫的query..Thank大家。 – Victor

回答

1

大致是這樣的:

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 
} 
+0

嗨,感謝您給予我的迴應。 – Victor