我有兩個表Cars
和Bookings
,我希望從Bookings
表中返回基於carld的Cars
表中的startdate和enddate。 這裏是我的表LINQ和連接?
汽車
ID Make Model Size
----------- --------------- --------------- ---------------
1 BMW 5Series Medium
2 Dacia Duster Large
3 Ford Mustang Large
預訂
ID CarID StartDate EndDate
----------- ----------- ---------- ----------
1 1 2017-02-01 2011-04-05
2 1 2017-05-11 2011-09-15
3 1 2017-09-09 2012-12-15
4 1 2017-07-12 2017-11-14
5 2 2017-01-16 2017-08-28
我是想這一點,但不斷收到錯誤,我不知道如何着手
string query3 = from c in db.Cars
join b in db.Bookings on c.ID equals b.CarID
select new { b.StartDate ,b.EndDate}.ToString();
[LINQ to SQL中的內連接的語法是什麼?](http://stackoverflow.com/questions/37324/what-is-the-syntax-for-an-inner-join- in-linq-to-sql) – itsme86
如果這打到一個數據庫,你使用哪個LINQ provider/ORM?如果您使用EF或LINQ to SQL,則不需要手動加入,只需在聲明外鍵時將(。。)集合在集合中即可。 –