将小时数添加到Linq日期结果 [英] AddHours to Linq Date result

查看:60
本文介绍了将小时数添加到Linq日期结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在linq日期结果中增加一些时间? 像这样的东西:

Is it possible to add some hours to linq date result ? something like this:

dim q = from a in somthing
        select new with {.x = a.date.AddHours(2)}

推荐答案

如果您使用的是linq-to-entities,并且希望在数据库服务器上执行命令,请尝试以下操作:

If you are using linq-to-entities and you want the command to be executed on the database server try this:

Dim q = from a in something 
        select new with { .x = EdmFunctions.AddHours(a.date, 2) }

EdmFunctionsSystem.Data.Objects命名空间(System.Data.Entity.dll的一部分)中的静态类.

EdmFunctions is static class in System.Data.Objects namespace (part of System.Data.Entity.dll).

这篇关于将小时数添加到Linq日期结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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