在EF6中,我尝试使用LINQ对一些值进行分组和求和,但是遇到以下错误:
无法创建类型为'System.Char'的常量值。在此上下文中,仅支持原始类型或枚举类型。
我查看了StackOverflow上六个类似问题,但没有找到我的问题。以下是查询语句:
var q = from c in _context.HoursProviderCosts
where c.PatientInsuranceCompanyName == insuranceName
&& c.HoursDate >= startDate
&& c.HoursDate <= endDate
group c by new { c.ID, c.PatientFirstName, c.PatientLastName } into g
select new Models.InsuranceCostListItem
{
PatientID = g.Key.ID,
PatientName = g.Key.PatientFirstName + ' ' + g.Key.PatientLastName,
Total = g.Sum(x => x.ProviderRate)
};
return q.ToList();
是我的分组有问题吗(我对此很陌生)?底层的EF6模型没问题(我可以展开_context.HoursProviderCosts
的结果视图并正常查看数据)。
谢谢。
编辑:方法签名:
public List<Models.InsuranceCostListItem> InsuranceCostsListItems(DateTime periodStart, string insuranceName) {
PatientName = g.Key.PatientFirstName + " " + g.Key.PatientLastName
- 15ee8f99-57ff-4f92-890c-b56153