实体框架linq包括

时间:2013-06-24 22:04:57

标签: c# mysql asp.net-mvc entity-framework

我有以下Linq查询我正在使用实体框架。

var res = from a in _db.Articles
                  from auth in a.Authors
                  where papers.Contains(a.JoomlaId)
                  select auth.Institution;

问题是我的机构类有一个名为“Type”的变量,类型为“InstitutionType”我需要包含,我不知道该怎么做。

1 个答案:

答案 0 :(得分:10)

var res = from a in _db.Articles.Include("Authors") 
                                .Include("Authors.Institution")
                                .Include("Authors.Institution.Type")
                  from auth in a.Authors
                  where papers.Contains(a.JoomlaId)
                  select auth.Institution;