Occasionally you have a need to write a SQL query that shows you data that was entered or modified in the past X seconds or minutes. The time on the computer executing the code could be several minutes off of the time on the database server. So how do you get the current time in the database in a Linq query? You can't call the GetDate() or GetUTCDate() functions within a Linq query so how would you do it? A quick little hack is to create a view that contains only the two functions, such as
Create View dbo.vw_SystemUtcTime
as
Select getdate() as Now, getutcdate() as UtcNow
Now drag this view in to the data context designer and you can join your queries to this view, for use in your where clause.