DateTime.Now converting

DateTime.Now converting

Postby Juflet » Thu 03 Mar 2016 12:59

I have a problem with DateTime type. Api Server and DB are on different servers. So we have some problem with sync time. When i used DateTime.UtcNow, PostgeSQL takes query with "CURRENT_TIMESTAMP AT TIME ZONE 'UTC')", but needed send requests from API server by datetime value of the DateTime.UtcNow. Is there any way to build query with value.
P.S. Sorry for my english.
Posts: 1
Joined: Thu 03 Mar 2016 12:42

Re: DateTime.Now converting

Postby Shalex » Fri 04 Mar 2016 11:56

Please use
Code: Select all
var a = DateTime.UtcNow;
[...].GetAll(true).Where(x => x.CreatedDate < a).OrderByDescending(x => x.CreatedDate)[...]
// converted to WHERE ("Extent1".createddate < :p__linq__0)

instead of
Code: Select all
[...].GetAll(true).Where(x => x.CreatedDate < DateTime.UtcNow).OrderByDescending(x => x.CreatedDate)[...]
// converted to WHERE ("Extent1".createddate < (CURRENT_TIMESTAMP AT TIME ZONE 'UTC'))
Devart Team
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Return to dotConnect for PostgreSQL