【发布时间】:2023-03-30 02:16:01
【问题描述】:
我自己有一个 SQL 查询
SELECT follow_up_date, MAX(last_contact_date) AS last_contact_date
FROM db_accounts_last_contacts p
GROUP BY p.account_id
我试过了
var queryTest = context.db_accounts_last_contacts.SqlQuery(@"SELECT follow_up_date, MAX(last_contact_date) AS last_contact_date
FROM db_accounts_last_contacts p
GROUP BY p.account_id");
但我收到此错误。
The data reader is incompatible with the specified 'dbModel.db_accounts_last_contacts'. A member of the type, 'id', does not have a corresponding column in the data reader with the same name.
我不想提取所有信息,因为此表可能稍后会更新,我只想提取这两列
【问题讨论】:
-
该 SQL 查询是否有效?由于它不在聚合函数中,您不需要在 group by 子句中包含 follow_up_date 吗?
标签: c# mysql sql-server linq