This solution is for any version of .NET: it should be more profitable for speed and network traffic than other solutions.
1) create a function on the SQL server:
CREATE FUNCTION [dbo].[GetSQLServerDate] () RETURNS datetime AS BEGIN DECLARE @Result datetime SELECT @Result = getdate() RETURN @Result END GO
2) Add a function to the LINQ to SQL diagram in the Stored Procedures section
3) Call your function from your code
THEDBDataContext DBConn = new THEDBDataContext (); DateTime dt = (DateTime) DBConn.GetSQLServerDate();
source share