我有两张表艺术家表(PK:ArtistID),电影表(PK:MovieID)和一张表格ArtistMovie。
如何使用Linq2Entities:
RentalEntities db = new RentalEntities();
以下是我的询问:
SELECT Movie.MovieName,
Movie.Year,
Artist.ArtistName,
Artist.Age
FROM Artist INNER JOIN ArtistMovie ON Artist.ArtistID = ArtistMovie.ArtistID
INNER JOIN Movie ON ArtistMovie.MovieID = Movie.MovieID
答案 0 :(得分:1)
我认为这应该有效:
from a in db.Artist
join am in db.ArtistMovie on a.ArtistID equals am.ArtistID
join m in db.Movie on am.MovieID equals m.MovieID
select new {
MovieName = m.MovieName,
Year = m.Year,
ArtistName = a.ArtistName,
Age = a.Age
};