我对LINQ不太熟悉。我需要将此查询转换为LINQ语句,以便在我的c#项目中使用。
感谢SELECT Galleries.GalleryTitle, Media.*
FROM Galleries
INNER JOIN Media ON Galleries.GalleryID = Media.GalleryID
WHERE (Galleries.GalleryID = 100)
var query = from g in db.Galleries
join m in db.Media on g.GalleryID equals m.GalleryID into gm
where g.GalleryID == 100
select new { g.GalleryTitle, Media = gm };
属性Media
将包含已加入的媒体实体列表。此外,如果您在图库实体中定义了导航属性,则:
var gallery = db.Galleries.Include("Media")
.FirstOrDefault(g => g.GalleryID == 100);