开发者

C# - EF4 - Get the server's DateTime.Now

开发者 https://www.devze.com 2023-03-06 01:16 出处:网络
I have a fat-client application which uses EF4 to MSSQL in the data layer. Before using EF4 (in p开发者_运维百科lain ADO.Net) I used to have a wrapper function which gets the SQL server\'s DateTime.No

I have a fat-client application which uses EF4 to MSSQL in the data layer. Before using EF4 (in p开发者_运维百科lain ADO.Net) I used to have a wrapper function which gets the SQL server's DateTime.Now (a simple SELECT GETDATE() wrapped in a C# client call).

Now I find that using SQL funcs and SPs which return simple value types is not-so-simple in EF4. What's the simplest&most efficent way to get the server's datetime-now in this scenario?

I'd like to avoid creating a wrapper entity for this, if possible.


DateTime ServerDate = Entities.CreateQuery<DateTime>("CurrentDateTime()").AsEnumerable().First();
0

精彩评论

暂无评论...
验证码 换一张
取 消