在LAMBDA形式LINQ选择重复计数 [英] LINQ Select Distinct Count in Lambda form
本文介绍了在LAMBDA形式LINQ选择重复计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定一个对象集合的LINQ表达式'项目'像这样的:
VAR总=(从项目中的项目选择item.Value).Distinct()。COUNT()
是否有可能将其转换为使用LINQ功能/ lambda表达式:
items.Select(???)是不同的(),COUNT()
解决方案
使用这样的:
items.Select(I => i.Value)。.Distinct()计数()
Given a linq expression of an object collection 'items' such as this:
var total = (from item in items select item.Value).Distinct().Count()
Is it possible to convert this to use linq functions/lambdas:
items.Select(???).Distinct().Count()
解决方案
Use this:
items.Select(i => i.Value).Distinct().Count()
这篇关于在LAMBDA形式LINQ选择重复计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文