本文介绍了在Linq分组,排名和前10名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 如何从列表中获得前十大保险金额请帮助。我试过这种方式,但它没有用。 公共类Top10Insurance { public string Amt {get ;组; } } 列表< Top10Insurance> result = InfoDB .GroupBy(a => a.InsuranceName)。选择(b => new Top10Insurance { Amt = b.Sum(c => c.BalanceAmount).ToString(),})。OrderByDescending(d => d.Amt).Take(10)。ToList(); 解决方案 他回答了自己的问题: Amt =( double )b.Sum(c = > c.BalanceAmount) How do i get the top 10 Insurance Amount from the List please help. I have tried in this way but its not working. public class Top10Insurance { public string Amt { get; set; } }List<Top10Insurance> result = InfoDB .GroupBy(a => a.InsuranceName) .Select(b => new Top10Insurance { Amt = b.Sum(c => c.BalanceAmount).ToString(), }).OrderByDescending(d => d.Amt).Take(10).ToList(); 解决方案 And he answered his own question:Amt = (double)b.Sum(c => c.BalanceAmount) 这篇关于在Linq分组,排名和前10名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-26 09:30