【发布时间】:2014-06-03 17:10:10
【问题描述】:
给定时区偏移值作为可为空的 int,我将如何将 linq 查询中的该值转换为该位置的当前时间?
var data = (from c in dbContext.Contacts
select new
{
c.Id,
TheirTime = DateTime.UtcNow.AddHours(c.TimezoneOffset)
})
这将返回“LINQ to Entities 无法识别方法 'System.DateTime AddHours(Double)' 方法,并且此方法无法转换为存储表达式。”错误。
【问题讨论】:
-
您可能想在此处查看我的问题的答案 (stackoverflow.com/questions/18901025/…)。