EF查询从TakeResultOperator转换为GroupResultOperator错误

时间:2019-01-14 08:21:29

标签: entity-framework asp.net-core

_dailySaleReportRepository.GetAll().Where(filter).GroupBy(p => p.StoreId).PageBy(input).Select(p => new DailySaleReportSearchResult()
        {
            StoreId = p.Key,
            StoreName = p.FirstOrDefault().StoreName,
            ParkName = p.FirstOrDefault().ParkName,
            AliMoney = p.Sum(g => g.AliMoney),
            CashMoney = p.Sum(g => g.CashMoney),
            CouponMoney = p.Sum(g => g.CouponMoney),
            DiscountAmount = p.Sum(g => g.DiscountAmount),
            FtMoney = p.Sum(g => g.FtMoney),
            MutonePayMoney = p.Sum(g => g.MutonePayMoney),
            MutoneTradeMoney = p.Sum(g => g.MutoneTradeMoney),
            OrederNumbers = p.Sum(g => g.OrederNumbers),
            RefundAmount = p.Sum(g => g.RefundAmount),
            RefundNumbers = p.Sum(g => g.RefundNumbers),
            TotalAmount = p.Sum(g => g.TotalAmount),
            TradeAmount = p.Sum(g => g.TradeAmount),
            WxMoney = p.Sum(g => g.WxMoney),
        }).ToList()

当我使用此代码获取总和时,我得到了一个错误

  

“无法将类型为'Remotion.Linq.Clauses.ResultOperators.TakeResultOperator'的对象强制转换为类型为'Remotion.Linq.Clauses.ResultOperators.GroupResultOperator'。”

但是当我第一次将组转换为字典然后使用select时,它将很好地工作。

0 个答案:

没有答案