【发布时间】:2018-09-21 08:14:34
【问题描述】:
我正在使用连接到 MySQL 的 LINQPAD 5。尝试运行以下表达式:
Productions.Where(p => p.Datetime.Year == 2018).GroupBy(p => p.Amount)
结果:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?.datetime)
LINQPAD 将表达式转换为以下 SQL 语句:
SELECT t0.amount, YEAR(A6139838?.datetime) AS c0
FROM productions AS t0
WHERE (YEAR(t0.datetime) = 2018)
GROUP BY t0.amount
问题来自于访问“.Year”,
.GroupBy(p => p.Datetime) //<-- this works
.GroupBy(p => p.Datetime.Year) //<--- MysqlException
【问题讨论】:
-
为什么是 YEAR(A6139838?.datetime)?
-
我不知道。这就是 LINQPAD 转换我的表达式的方式