我有两个表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,则不需要手动加入,只需在声明外键时将(。。)集合在集合中即可。 –