"Use UTC for DateTime" backend setting for ORM Classic

8 posts, 1 answers
  1. Alex
    Alex avatar
    22 posts
    Member since:
    Jun 2010

    Posted 26 Oct 2010 Link to this post

    Hello, we are using OpenAcess ORM Classic in our project. So far we found classic version to fit better our needs, but have encounter problem with "Use UTC for DateTime" backend setting. It seems that if we setting this value to true manually in code it's beeing ignored.

    In our entities we created fields like CreatedDate and LastUpdatedDate, and we set option in forward mapping to set these values to current date. We want these dates to be stored in UTC timezone, for this reason we set "Use UTC for DateTime" to true when we creating database instance, e.g.

    _theObjectScopeProvider.myDatabase = Telerik.OpenAccess.Database.Get("LocalExpressConnection");
    _theObjectScopeProvider.myDatabase.BackendConfiguration.Runtime.UseUTCForAutoSetValues = true;

    But nevertheless dates are inserted in database in local time zone.

    Is there any workaround for this. Any help will be appreciated. Thanks.
  2. Alex
    Alex avatar
    22 posts
    Member since:
    Jun 2010

    Posted 27 Oct 2010 Link to this post

    Any advice from Telerik team?
    Thanks.
  3. DevCraft banner
  4. Answer
    Ady
    Admin
    Ady avatar
    588 posts

    Posted 29 Oct 2010 Link to this post

    Hello Alex,

     You need to set this option before you obtain an instance of the 'Database' i.e before the Database.Get call.
    You can set the option by adding this node to the app.config file
    <useUTCForAutoSets>True</useUTCForAutoSets>

    Hope this helps.

    Greetings,
    Ady
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Alex
    Alex avatar
    22 posts
    Member since:
    Jun 2010

    Posted 29 Oct 2010 Link to this post

    Thanks! It works!

    Just more detailed instruction. You need to put this node into <backendConfiguration> element.
    So it should look something like this:

    <backendconfiguration id="mssqlConfiguration" backend="mssql">
            <dbNamegen.useModelNames>True</dbNamegen.useModelNames>
            <mappingname>mssqlMapping</mappingname>
            <useUTCForAutoSets>True</useUTCForAutoSets>
          </backendconfiguration>
  6. Sunita
    Sunita avatar
    25 posts
    Member since:
    May 2009

    Posted 28 Jul 2011 Link to this post

    Hi ,

    I tried this and it doesn't seem to be working. Is it  
    <useUTCForAutoSets>True</useUTCForAutoSets>
    or
    <useUTCForAutoSetDates>True</useUTCForAutoSetDates>


    I am using version 2011 Q2 (2011.2.713.3) - ORM Classic (reverse map/forward map)
  7. Ady
    Admin
    Ady avatar
    588 posts

    Posted 29 Jul 2011 Link to this post

    Hi Sunita,

    It is 'useUTCForAutoSets'. There is no setting with the name 'useUTCForAutoSetDates'. Can you ensure that connectionId used to obtain the 'Database' instance is the same as specified in the app.config file and that this connection id resolves to the appropriate <backendConfiguration> element.
    You can also send us your app.config file and I can verify it.

    Kind regards,
    Ady
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  8. Sunita
    Sunita avatar
    25 posts
    Member since:
    May 2009

    Posted 29 Jul 2011 Link to this post

    Hi Ady,

    I have sent you the app.config via a support ticket. Please let me know a solution.
    Thanks,
    Sunita
  9. Ady
    Admin
    Ady avatar
    588 posts

    Posted 01 Aug 2011 Link to this post

    Hi Sunita,

     As replied to you via the support thread, the '<useUTCForAutoSets>true</useUTCForAutoSets>' setting applies to only those fields whose value is automatically set by the OpenAcess runtime via the 'Set field to current date during create/update' setting i.e fields with the following mapping in the app.config file
    <extension key="autoset" value="..."/> where value can be 'created','modified' or 'both'.

    Do let me know if your settings confirm to the above.

    Regards,
    Ady
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Back to Top
DevCraft banner