不支持Linq-to-EF DateTime.ToLocalTime [英] Linq-to-EF DateTime.ToLocalTime not supported

查看:65
本文介绍了不支持Linq-to-EF DateTime.ToLocalTime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DateTime.ToLocalTime.

有什么选择?我快要疯了.

What's the alternative? I am running out of idea.

推荐答案

而不是在Linq查询中使用.ToLocalTime(),而是在查询之外对参数使用相反的转换.

Instead of using .ToLocalTime() inside your Linq query, use the opposite conversion outside of the query on the parameters.

var dateUniversal = dateParam.ToUniversalTime();

var query = myTable.Where( t => t.DateTime > dateUniversal );

这篇关于不支持Linq-to-EF DateTime.ToLocalTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆