奇怪的問題:簡單EF 5查詢帶回沒有結果
試圖做一個簡單的查詢,對我的電子郵件通知表:
using (MyContext context = new MyContext())
{
IQueryable<EmailNotification> query = context.EmailNotifications.Where(q => (q.LastSendAttemptStatus == EmailNotificationSendStatuses.Pending) || (q.LastSendAttemptStatus == EmailNotificationSendStatuses.Resend));
return query.ToList();
}
它帶回沒有結果,即使排在那裏。實際上,我看着它生成的SQL並且沒有任何更改就運行它,並且它確實爲帶來了正確的結果。
SELECT
[Extent1].[EmailNotificationID] AS [EmailNotificationID],
[Extent1].[From] AS [From],
[Extent1].[To] AS [To],
[Extent1].[Cc] AS [Cc],
[Extent1].[Bcc] AS [Bcc],
[Extent1].[Subject] AS [Subject],
[Extent1].[Body] AS [Body],
[Extent1].[LastSendAttemptOn] AS [LastSendAttemptOn],
[Extent1].[LastSendAttemptStatus] AS [LastSendAttemptStatus],
[Extent1].[FailureComments] AS [FailureComments]
FROM [dbo].[EmailNotifications] AS [Extent1]
WHERE (0 = CAST([Extent1].[LastSendAttemptStatus] AS int)) OR (3 = CAST([Extent1]. [LastSendAttemptStatus] AS int))
任何提示我應該檢查什麼?
您是否更改過表格定義 - 是否需要重新生成edmx文件?如果你調試,你可以手動枚舉結果? – Dave 2013-02-18 10:56:19
這是代碼第一,所以沒有涉及edmx文件。沒有結果可以列舉。實體沒有變化。 – 2013-02-18 11:00:17