您的位置:首页 > 其它

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();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: