LINQ 查询中子级的 OrderBy
大家好,
我有一个 user 实体,其中包含与 role 实体的一对多关系
所以使用这个 linq 表达式:
from user in USER_TABLE.Include("USERROLE_TABLE")
order by user.Name
select user
我小时候可以获得具有相关角色的用户。 我的问题是我想获取按字母顺序排列的每个用户的角色。 我怎样才能做到这一点?我用谷歌搜索了很多,但没有找到任何东西,
提前谢谢!
Possible Duplicate:
EF4 LINQ Ordering Parent and all child collections with Eager Loading (.Include())
Hello everybody
I have a user entity who contains a one to many relationship with a role entity
So with this linq expression :
from user in USER_TABLE.Include("USERROLE_TABLE")
order by user.Name
select user
I can get users with related roles as a child.
My problem is that i want to get roles of each user ordered alphabetically.
How can i do that ? I googled a lot and don't find anything
Thank's by advance !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,为了澄清一下,您有一个表,其中本质上包括:
并且您希望最终得到:
如果是这种情况,那么您正在查看“orderby,thenby”,我认为在 LINQ 中它是由逗号表示的在 LINQ 语句的那部分:
这是您要寻找的吗?
So, just to clarify, you have a table which includes essentially:
and you want to end up with:
If that's the case, then you're looking at an "orderby, thenby", which in LINQ I believe is indicated by a comma in that part of the LINQ statement:
Is that what you're looking for?