GETDATE()使用实体框架 [英] GetDate() using Entity Framework

查看:117
本文介绍了GETDATE()使用实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用实体框架,并从SQL服务器的日期。在LINQ这样的老办法是低于但我需要的东西实体框架:

I am trying to use entity framework and get the date from the SQL server. The old way of doing this in LINQ is below but i'm needing something for the entity framework:

Partial Public Class ActivityActionsDataContext
<[Function](Name:="GetDate", IsComposable:=True)> _
Public Function GetSystemDate() As DateTime
    Dim mi As MethodInfo = TryCast(MethodBase.GetCurrentMethod(), MethodInfo)
    Return DirectCast(Me.ExecuteMethodCall(Me, mi, New Object() {}).ReturnValue, DateTime)
End Function

末级

推荐答案

您是否尝试过使用 DateTime.Now DateTime.UtcNow ?我想的认为的,将被查询翻译器转换成 GetSystemDate()

Have you tried using DateTime.Now or DateTime.UtcNow? I'd like to think that would be converted into GetSystemDate() by the query translator.

这篇关于GETDATE()使用实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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