Reputation: 708
I have a client-server architechture where all the processes connects to the same database (SQL Server) and all the communication between the processes is done through the database. I use LINQ (System.Data.Linq.DataContext) to interact with the database.
Since the different processes may have assynchronous times, and comparing DateTimes is something very relevant to my application, I want whenever a process needs to write the current DateTime in the database, I want it to use the current time of the SQL Server, instead of the OS current time. It may need the SQL Server's time also to compare with values it reads.
My question is basically how to access the SQL Server time through LINQ; that would be enough to I make what I want, but any better suggestion is appreciated.
Upvotes: 2
Views: 364
Reputation: 5752
You can have a trigger or a default value for the date/time field so that the time inserted is obtained from the database and not passed from your client to the server. Example 1: SQL Server Default Date Time Example 2: SQL Server Trigger for date update.
Upvotes: 4