我有一组从数据库中提取的错误。时间存储为 UTC,但我想将其转换为 CST:
var errors = _errorsRepository.Errors.
Select(e => new ErrorViewModel
{
ErrorId = e.ErrorId,
Application = e.Application,
Host = e.Host,
Type = e.Type,
Source = e.Source,
Message = e.Message,
User = e.User,
StatusCode = e.StatusCode,
TimeUtc = TimeZoneInfo.ConvertTimeFromUtc(
e.TimeUtc, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time")),
Sequence = e.Sequence,
AllXml = e.AllXml
});
但我收到了这个错误:
LINQ to Entities 无法识别方法 'System.DateTime ConvertTimeFromUtc(System.DateTime, System.TimeZoneInfo)' 方法,并且此方法无法转换为存储表达式
有谁知道我能做些什么来解决这个问题?