字典无法从“ <匿名类型:”转换

这是我的代码:

 var groupedDataDictionary = products
                .Where(p => p.ProductType == ProductType.ValueType)
                 .GroupBy(p => new { p.OfficeDebitId, p.OfficeDebitDate, p.PaymentMethod }) 
                .ToDictionary(x => x.Key, x => x.Sum(p => p.Amount)); 



 var result = products.Select(p => new ResponseDto()
        {
            customer_id = p.CustomerId, 
            office_debit_date = p.OfficeDebitDate.Value.ToString(),
            office_debit_id = p.OfficeDebitId.ToString(),
            office_debit_total = groupedDataDictionary[new { p.OfficeDebitId, p.OfficeDebitDate, p.PaymentMethod }].Sum().ToString(), // this line causes error
            payment_method = p.PaymentMethod.Value.ToString(),
        }).ToList();

When assiging office_debit_total on that line it says:

错误CS1503参数1:无法从''转换为'(string   OfficeDebitId,System.DateTime? OfficeDebitDate,   Enumerations.PaymentMethod?付款方法)'
评论