public struct CardGrouping
{
public string Name { get; set; }
public int Count { get; set; }
}
public List<CardGrouping> GetCardGrouping(IQueryable<Areas.RetailShop.Models.FPSinformation> queryable, Expression<Func<Areas.RetailShop.Models.FPSinformation, string>> groupingFunction)
{
return queryable.GroupBy(groupingFunction)
.Where(x => x.Key != null)
.Select(x => new CardGrouping
{
Name = x.Key,
Count = x.Sum(groupingFunction)
}).ToList();
}
我试图做这样的事情,但得到的错误不包含定义为的GroupBy
IQueryable<FPSinformation>
不包含“的GroupBy” 的定义和最佳推广方法重载ParallelEnumerable.GroupBy<string, int>(ParallelQuery<string>, Func<string, int>)
需要一个类型的接收器ParallelQuery<string>
我在做什么错了?
编辑
var data1 = fpslist.GroupBy(x => x.Ration_Card_Type1)
.Select(x => new
{
CardType_Name = x.Key,
CardType_Count = x.Sum(y => y.Ration_Card_Count1)
}).ToList();
这是我想实际的代码优化
@Neel它已经存在 –