我有我自己的SQL查詢轉換SQL查詢LINQ查詢,但只有選擇特定值返回
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,因爲它不在聚合函數中? – juharr 2014-11-05 16:52:30