在Select Distinct LINQ Expression中修改查询。 [英] Modify query in Select Distinct LINQ Expression.
本文介绍了在Select Distinct LINQ Expression中修改查询。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨团队,
很高兴见到你们。我在LINQ Expression中编写了查询。
我想在Select distinct LINQ表达式中修改该查询,是否可能。请指导ME。查询如下:
Hi Team,
Nice to see you all. I have written the query in LINQ Expression.
I want to modify that query in Select distinct LINQ expression,is it possible .please Guide ME.The Query is as follows:
string[] matchID = zteBbhRecords.Cast<IZteBbh>().Select(zteBbh => (zteBbh.CombinedMaster as ICombinedMaster).CellId.ToString()).GroupBy(item => item).Where(items => items.Count() > 1).Select(item => item.Key).ToArray();
推荐答案
因此,使用Distinct()。ToArray(),我们可以轻松获取不同的值并将它们转换为数组。
So, using Distinct().ToArray(), we can easily get the distinct values and convert them to array.
string[] matchID = zteBbhRecords.Cast<IZteBbh>()
.Select(zteBbh => (zteBbh.CombinedMaster as ICombinedMaster)
.CellId.ToString()).GroupBy(item => item)
.Where(items => items.Count() > 1)
.Select(item => item.Key).Distinct().ToArray();
这篇关于在Select Distinct LINQ Expression中修改查询。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文