c# - Entity Framework linq 包括

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

我在使用 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”,我需要包含它,但我不知道该怎么做那个。

最佳答案

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;

关于c# - Entity Framework linq 包括,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17285924/

相关文章:

c# - 解析来自 Httpwebrequest 的 Json 响应

mysql - 20-30 个并发 mysql 连接导致 RDS 飙升至 80% 以上

javascript - 将 int 数组传递给 MVC Controller

c# - Mono 是否支持 System.Drawing 和 System.Drawing.Printing?

c# - C#中的选择语句

php - 通过 URL 传递值

mysql - codeigniter 购物车和多个表

asp.net-mvc - 如果我在操作定义中使用异步任务,该操作是否应该与异步相关?

c# - 如果 .Count == 0 条件运算符不显示

c# - 更新面板或 Ajax 调用