我正在使用连接到mysql的linqpad5。正在尝试运行以下表达式:
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
截图:
1条答案
按热度按时间0tdrvxhp1#
试试这个
方法1:
方法2:
将datetime的属性名更改为其他名称。实际上名称与sql数据类型相同。可能会有冲突