ef导航属性
2015-08-14 17:30
309 查看
https://msdn.microsoft.com/en-us/data/jj574232.aspx
场景是 A表中有B,B表中又C。都是一堆多的关系。怎样Mapping是个问题啊。
var blogs1 = context.Blogs
.Include(b => b.Posts.Select(p => p.Comments))
.ToList();
// Load all blogs, all related posts, and all related comments
var blogs1 = context.Blogs
.Include(b => b.Posts.Select(p => p.Comments))
.ToList();
// Load all users their related profiles, and related avatar
var users1 = context.Users
.Include(u => u.Profile.Avatar)
.ToList();
// Load all blogs, all related posts, and all related comments
// using a string to specify the relationships
var blogs2 = context.Blogs
.Include("Posts.Comments")
.ToList();
// Load all users their related profiles, and related avatar
// using a string to specify the relationships
var users2 = context.Users
.Include("Profile.Avatar")
.ToList();
returnValue=context.Assessments.Where(item=>item.State== AssessmentType.Used).Include(item=>item.QuestionList.Select(p=>p.Options)).ToList();
场景是 A表中有B,B表中又C。都是一堆多的关系。怎样Mapping是个问题啊。
var blogs1 = context.Blogs
.Include(b => b.Posts.Select(p => p.Comments))
.ToList();
// Load all blogs, all related posts, and all related comments
var blogs1 = context.Blogs
.Include(b => b.Posts.Select(p => p.Comments))
.ToList();
// Load all users their related profiles, and related avatar
var users1 = context.Users
.Include(u => u.Profile.Avatar)
.ToList();
// Load all blogs, all related posts, and all related comments
// using a string to specify the relationships
var blogs2 = context.Blogs
.Include("Posts.Comments")
.ToList();
// Load all users their related profiles, and related avatar
// using a string to specify the relationships
var users2 = context.Users
.Include("Profile.Avatar")
.ToList();
returnValue=context.Assessments.Where(item=>item.State== AssessmentType.Used).Include(item=>item.QuestionList.Select(p=>p.Options)).ToList();
相关文章推荐
- 数学题1
- Android HttpClient POST JSON Restful-web-services
- StrangeIoc框架的简要介绍
- The error is weblogic.descriptor.DescriptorException: Unmarshaller failed
- 小孩报数问题(3750)
- Android:EditText 多行显示及所有属性
- 互联网七字诀:专注、极致、口碑、快(雷总提出)
- JAVA反射机制
- C++内存管理
- OS X下使用pip 安装Pillow
- 《算法竞赛入门经典》第二章精选
- 字符设备驱动范例
- Linux深入篇之四:配置Nginx+Tomcat动静分离架构
- LDAP(轻量目录访问协议)
- Shiro 与 Spring框架整合
- eclipse中j2ee(struts2)部署及相关问题释疑
- 【Huffman树】【贪心】【NOI 2015】【bzoj 4198】荷马史诗
- LeetCode-Binary Tree Level Order Traversal
- AX系统金额缩写MST的含义
- 【Socket计划】使用C++实现Server结束Client结束