作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
这是 EF6。我可以在我的查询中包含 .Include()
方法(没有双关语),以便从相关表中预先加载信息。但是看起来 .Include() 方法只接受一个字符串参数。有没有办法以强类型的方式做到这一点?因此,例如,我可以编写类似 MyDB.catalog_item.Include(i => i.picture)
的内容,而不是编写 MyContext.catalog_item.Include("picture")
获得智能感知等优势。
最佳答案
是的,System.Data.Entity 中有一个强类型变体
用法是
.Include(i => i.Property)
引用页面还提供了有关如何在集合中包含集合和属性的示例。
例子:
query.Include(e => e.Level1Collection.Select(l1 => l1.Level2Reference)).
关于c# - DbQuery.Include() 方法 : Is there a strong-typed variant?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23136299/
我是一名优秀的程序员,十分优秀!