var data = (from prod in db.ref_ProductAvail
group prod by new { prod.storeOfAccount, prod.serviceName } into g
orderby g.Key.storeOfAccount
join branch in db.ref_Branch
on g.Key.storeOfAccount equals branch.code
select new
{
branchCode = g.Key.storeOfAccount,
branchName = branch.description,
serviceName = g.Key.serviceName,
svcCount = g.Key.serviceName.Count()
}).ToList();
My Query适用于LINQPAD但在C#>上抛出此错误 DbExpressionBinding需要一个带有ResultType.Parameter名称的输入表达式:input,
因为我搜索了一个解决方案,但我找不到问题的确切解决方案,同时删除ToList
或使用IEnumerable
确实有效,但我无法使用foreach
。
答案 0 :(得分:0)
是的,你做得对。错误应该在public static Optional<Integer> getMonthNumber(String month) {
if (month != null)
switch (month.toLowerCase()) {
case "january": return Optional.of(1);
case "february": return Optional.of(2);
case "march": return Optional.of(3);
case "april": return Optional.of(4);
case "may": return Optional.of(5);
case "june": return Optional.of(6);
case "july": return Optional.of(7);
case "august": return Optional.of(8);
case "september": return Optional.of(9);
case "october": return Optional.of(10);
case "november": return Optional.of(11);
case "december": return Optional.of(12);
}
return Optional.empty();
}
中,因为此表达式正在尝试计算g.Key.serviceName.Count()
字符串中的字符数。哪个不能转换为sql。如果你想达到同样的目的,你可以试试像
serviceName
尚未测试