如何从Linq中的子表中选择列到实体

编程入门 行业动态 更新时间:2024-10-28 08:30:09
本文介绍了如何从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中的子表中选择列到实体

本文发布于:2023-10-19 11:20:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1507339.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实体   Linq   子表中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!