2013-01-02 99 views

回答

4
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將包含加入媒體實體的名單。另外,如果您在Gallery實體中定義了導航屬性,那麼:

var gallery = db.Galleries.Include("Media") 
       .FirstOrDefault(g => g.GalleryID == 100); 
+1

非常感謝! – Maddhacker24

相關問題