java Linq GroupBy with Having

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java Linq GroupBy with Having相关的知识,希望对你有一定的参考价值。


Like this:

from c in db.Company
group c by c.Name into grp
where grp.Count() > 1
select grp.Key
Or, using the method syntax:

Company
    .GroupBy(c => c.Name)
    .Where(grp => grp.Count() > 1)
    .Select(grp => grp.Key);
    
    
var result = ManageBucket_DocumentLists
	.Where(b => b.FileName != null)

	 .Where(b => b.IsActive.Equals(true))
	 .Where(b => b.IsDeleted.Equals(false))
	 .Where(b => b.SourceSystemName.Equals("Documentum"))
	 .GroupBy(c => c.FileName)
	.Where(grp => grp.Count() > 1)
	.Select(grp => new
	{
		grp.Key,
		//grp.Key.FileVersion,
		v = grp.Max(g => g.FileVersion),
		matches = grp.Count(),

	});

result.Dump();

以上是关于java Linq GroupBy with Having的主要内容,如果未能解决你的问题,请参考以下文章

Linq 中的 Groupby 和 where 子句

c# linq groupby是默认去掉重复行吗

linq GroupBy

Linq:GroupBy、Sum 和 Count

groupby java

Linq 中按照多个值进行分组(GroupBy)