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

DateTime in UTC? #86

Closed
cameronmr opened this issue Jun 3, 2016 · 9 comments
Closed

DateTime in UTC? #86

cameronmr opened this issue Jun 3, 2016 · 9 comments

Comments

@cameronmr
Copy link

I am using SqlFu v2 with mysql and would like all DateTime's to be set to DateTimeKind.Utc. Can you recommend a way to do this for all SqlFu queries?

I can certainly force UTC manually on the DateTime properties for the objects I get back from SqlFu - but we have many different objects and I would rather not have to do the same thing over and over.

Thanks for your awesome library!
Cameron

@cameronmr
Copy link
Author

Forgot to mention that all dates are being saved as UTC.

@sapiens
Copy link
Owner

sapiens commented Jun 3, 2016

Hm, I always work with GMT dates and never had a problem, but anyways... try this in your app's start up class

PocoFactory.RegisterConverterFor<DateTime>(obj=>{ /* ensure it's UTC */}) 

@cameronmr
Copy link
Author

Thanks for the quick response!

I have tried what you suggested but the converter never gets called:

   PocoFactory.RegisterConverterFor<DateTime>(o =>

        {

            return DateTime.SpecifyKind((DateTime) o, DateTimeKind.Utc);

        });

I placed this in my Application_Start and a few other places (just in case) with no luck. Any other thoughts?

Cheers

Cameron

From: Mike Mogosanu [mailto:[email protected]]
Sent: Friday, 3 June 2016 21:15
To: sapiens/SqlFu [email protected]
Cc: cameronmr [email protected]; Author [email protected]
Subject: Re: [sapiens/SqlFu] DateTime in UTC? (#86)

Hm, I always work with GMT dates and never had a problem, but anyways... try this in your app's start up class

PocoFactory.RegisterConverterFor(obj=>{ /* ensure it's UTC */})


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #86 (comment) , or mute the thread https://github.com/notifications/unsubscribe/AC8AS6y5yihs-_fQgCADUGUsHFiawGDhks5qICjKgaJpZM4ItWZ- .

@sapiens
Copy link
Owner

sapiens commented Jun 4, 2016

Can you show me a code sample of the query itself?

@sapiens
Copy link
Owner

sapiens commented Jun 4, 2016

Ok, I think I've found the problem. The mapper invokes directly reader.GetDateTime as an optimization and it doesn't check the converters. I'm thinking if I can come up with a simple solution.

@sapiens
Copy link
Owner

sapiens commented Jun 4, 2016

Fixed it. You can update your nuget pack now (v.2.3.14).

@sapiens sapiens closed this as completed Jun 4, 2016
@cameronmr
Copy link
Author

Thanks Mike,

I tried the new package and the DateTime converter worked. Unfortunately, I was seeing consistent database timeouts (mysql/mariadb) when issuing multiple updates in a single transaction. Rolling back to SqlFu 2.3.12 resolved the timeout issue.

I haven’t had a chance to dig deeper. Any changes you are aware of that may be causing the timeout/deadlock – or anything I can do to help you identify the problem?

Thanks

Cameron

From: Mike Mogosanu [mailto:[email protected]]
Sent: Saturday, 4 June 2016 23:24
To: sapiens/SqlFu [email protected]
Cc: cameronmr [email protected]; Author [email protected]
Subject: Re: [sapiens/SqlFu] DateTime in UTC? (#86)

Fixed it. You can update your nuget pack now (v.2.3.14).


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #86 (comment) , or mute the thread https://github.com/notifications/unsubscribe/AC8ASxbS-yxOVhkGPl93oyM_0_uuANDlks5qIZhygaJpZM4ItWZ- .

@cameronmr
Copy link
Author

Hi Mike,
I suspect the timeout I mentioned below has nothing to do with your changes. I will get back to you with a confirmation tomorrow.
Thanks
Cameron
On 7 Jun 2016 8:12 am, Cameron Rochester [email protected] wrote:Thanks Mike, I tried the new package and the DateTime converter worked. Unfortunately, I was seeing consistent database timeouts (mysql/mariadb) when issuing multiple updates in a single transaction. Rolling back to SqlFu 2.3.12 resolved the timeout issue. I haven’t had a chance to dig deeper. Any changes you are aware of that may be causing the timeout/deadlock – or anything I can do to help you identify the problem? ThanksCameron From: Mike Mogosanu [mailto:[email protected]] Sent: Saturday, 4 June 2016 23:24To: sapiens/SqlFu [email protected]: cameronmr [email protected]; Author [email protected]: Re: [sapiens/SqlFu] DateTime in UTC? (#86) Fixed it. You can update your nuget pack now (v.2.3.14).—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

@cameronmr
Copy link
Author

Hi Mike,

I can confirm there was a problem on our side and your changes work perfectly. Thanks again for the rapid response!

Cheers

Cameron

From: Cameron Rochester [mailto:[email protected]]
Sent: Tuesday, 7 June 2016 18:16
To: 'sapiens/SqlFu' [email protected]
Subject: RE: [sapiens/SqlFu] DateTime in UTC? (#86)

Hi Mike,

I suspect the timeout I mentioned below has nothing to do with your changes. I will get back to you with a confirmation tomorrow.

Thanks
Cameron

On 7 Jun 2016 8:12 am, Cameron Rochester <[email protected] mailto:[email protected] > wrote:

Thanks Mike,

I tried the new package and the DateTime converter worked. Unfortunately, I was seeing consistent database timeouts (mysql/mariadb) when issuing multiple updates in a single transaction. Rolling back to SqlFu 2.3.12 resolved the timeout issue.

I haven’t had a chance to dig deeper. Any changes you are aware of that may be causing the timeout/deadlock – or anything I can do to help you identify the problem?

Thanks

Cameron

From: Mike Mogosanu [mailto:[email protected]]
Sent: Saturday, 4 June 2016 23:24
To: sapiens/SqlFu <[email protected] mailto:[email protected] >
Cc: cameronmr <[email protected] mailto:[email protected] >; Author <[email protected] mailto:[email protected] >
Subject: Re: [sapiens/SqlFu] DateTime in UTC? (#86)

Fixed it. You can update your nuget pack now (v.2.3.14).


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #86 (comment) , or mute the thread https://github.com/notifications/unsubscribe/AC8ASxbS-yxOVhkGPl93oyM_0_uuANDlks5qIZhygaJpZM4ItWZ- .

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