Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTimeOffset #221

Closed
zuosc opened this issue Aug 6, 2017 · 2 comments
Closed

DateTimeOffset #221

zuosc opened this issue Aug 6, 2017 · 2 comments

Comments

@zuosc
Copy link

zuosc commented Aug 6, 2017

Because I do not know how to use linq query,so i can only use sql query,

This is code

var sql = $"SELECT * FROM base_authenticateLogs WHERE recordtime <= NOW() AND username = '{userName}' AND (reservedfield ->> 'setup') =  'Setup1' ORDER BY id DESC LIMIT {limit}"; 

var entitys = this.DbContext.Set<AuthenticateLogEntity>().FromSql(sql);

and the 'recordtime' type is DateTimeOffset ,and my time zone is '+08:00'.

in database, i execute this sql ,the value is
c1qkrn42 9tk a 3y 2 86
The result is right!

but in code, the value is
image
The time zone is '+00:00'??????

so,where is wrong?

can you help me to solve it?

//-----------------------------------------------------------
Extra information:

on OnModelCreating:

 b.Property(p => p.RecordTime).HasColumnName("recordtime");

on Entity:

/// <summary>
/// Record Time
/// </summary>
public DateTimeOffset RecordTime { get; set; }
@zuosc
Copy link
Author

zuosc commented Aug 8, 2017

Hello?

@roji
Copy link
Member

roji commented Aug 9, 2017

It would help if you posted the actual table schema you're querying (with column types).

However, looking at your SQL, I'm seeing reservedfield ->> 'setup'. At the moment, the Npgsql EF Core provider doesn't provide any way to generate this JSON operation from a LINQ query - this feature is tracked by #4. So regardless of any issue with DateTimeOffset, you're going to have to continue using raw SQL until #4 is done.

Let me know if you have any further questions/issues.

@roji roji closed this as completed Aug 9, 2017
@roji roji added the invalid label Aug 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants