Page 1 of 1

DateTime.Now converting

Posted: Thu 03 Mar 2016 12:59
by Juflet
Hi!
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.

Re: DateTime.Now converting

Posted: Fri 04 Mar 2016 11:56
by Shalex
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'))