GroupBy之后如何在组上强制执行条件 [英] How enforce conditions on the groups after GroupBy

查看:80
本文介绍了GroupBy之后如何在组上强制执行条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只希望在满足某些条件的GroupBy之后获得这些组.我该怎么做?在SQL中,我们有具有"子句,在LINQ中是否有类似的东西?
我不想在foreach循环中使用if-else.

I want to get only those groups after GroupBy which satisfies some condition. How can I do do this? In SQL we have the ''having'' clause, do we have something similar in LINQ?
I don''t want to use if-else within the foreach loop.

推荐答案

您始终可以在分组之前过滤数据.

然后,您可以对上述结果进行另一个LINQ查询,并根据需要进行过滤.
You can always filter your data before you group.

And you can do another LINQ query on the above results and filter as needed.


这篇关于GroupBy之后如何在组上强制执行条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆