本文介绍了如何从Linq中的子表中选择列到实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
美好的一天, 如何在我的linq查询中包含二级表列。我不希望.Net执行延迟加载,因为这些表还有其他表链接。 表是 测验: Id 名称 问题: Id 名称 quizId 期权: id 名称 QuestionId 测验和问题有一对多关系,问题到选项表也有一对多关系。
Good day, How do I include 2nd level table column in my linq query. I don't want .Net to perform lazy loading because there are other table link to these tables. The table are Quiz: Id Name Questions: Id Name quizId Options: id Name QuestionId Quiz and Questions has one to many relationship and Questions to Option table also has one to many relationship.
var quiz=db.Quiz.include(a=>a.Questions)......ToList();如何在linq查询中包含Options列。
How can I include Options column in my linq query.
推荐答案尝试: Try: var quiz = db.Quiz.Include(a => a.Questions.Select(q => q.Options)) ... .ToList();
使用实体框架加载相关实体 - 初学者入门 [ ^ ]
更多推荐
如何从Linq中的子表中选择列到实体
发布评论