【发布时间】:2013-07-13 09:07:43
【问题描述】:
我需要在使用 lambda 表达式的 linq 查询中调用 ToShortDateString:
toRet.Notification = Repositories
.portalDb.portal_notifications.OrderByDescending(p => p.id)
.FirstOrDefault(p => p.date.ToShortDateString() == shortDateString);
但我得到了错误:
“System.NotSupportedException”类型的异常发生在 System.Data.Entity.dll 但未在用户代码中处理
附加信息:LINQ to Entities 无法识别该方法 'System.String ToShortDateString()' 方法,并且该方法不能 翻译成商店表达式。
考虑到我确实需要使用ToShortDateString(),我该怎么办?
谢谢。
【问题讨论】:
-
这个帖子可能有帮助:stackoverflow.com/questions/5370402/…
-
这个帖子应该有帮助:stackoverflow.com/questions/18233495/…
标签: c# linq entity-framework