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();
精彩评论