GUID primary key

8 posts, 0 answers
  1. Jaimie
    Jaimie avatar
    33 posts
    Member since:
    Mar 2008

    Posted 27 Oct 2009 Link to this post

    hey.

    I have a table with a GUID type primary key.

    How can i reverse map the table and generate the classs with the GUID primary key? what should i add for the config file to allow generating new guid for insert? I use OpenAccessDataSource with RadGrid.

    Please provide a detailed example if you can.

    thanks
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 02 Nov 2009 Link to this post

    Hi Jaimie,

    You can generate the class files as you normally do for each of your other tables as the uniqueidentifier is correctly mapped to Guid by Telerik OpenAccess ORM. What is left is to run the forward mapping wizard and change the Key Generator option for the class from none to GUID. This will let OpenAccess generate and insert guids for your primer keys. Additional information can be found here.

    Greetings,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Marco Tambalo
    Marco Tambalo avatar
    6 posts
    Member since:
    Jan 2010

    Posted 08 Jan 2010 Link to this post

    When creating a new object scope (ObjectScopeProvider.GetNewObjectScope()), the ORM system always displays the error:
    Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'voa_keygen'.
    I am using Guid for the Id, Key Generator has been set to GUID and NONE.
    What seems to be the problem with this?
  5. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 08 Jan 2010 Link to this post

    Hello Marco Tambalo,
    The problem is that OpenAccess does not find the mapping where you did specify the Guid key. You have to call AdjustDynamicLoad on the ObjectScopeProvider1 class before you get the first database or have a <reference> entry in the app.config of your application. How do you get the ObjectScopes?

    All the best,
    Jan Blessenohl
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Marco Tambalo
    Marco Tambalo avatar
    6 posts
    Member since:
    Jan 2010

    Posted 08 Jan 2010 Link to this post


    I just use:

    IObjectScope scope = ObjectScopeProvider.GetNewObjectScope();

    Please note that this is in a WindowsForms project, with the persistent classes/objects in a class library project (the ORM project), and I am using class inheritance hierarchy.

    I did not encounter this error in previous projects, with same setup, except that those are WebApplications plus WCF.

    BTW, where can I find the AdjustDynamicLoad method?
  7. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 09 Jan 2010 Link to this post

    Hi Marco,

    The Adjustfor dynamic load is located in the ObjectScopeProvider.cs file... Basically it handcrafts a xml configuration( with the mentioned <reference> tag) to be passed to the Database.Get() method.

    Regards

    Henrik
  8. Marco Tambalo
    Marco Tambalo avatar
    6 posts
    Member since:
    Jan 2010

    Posted 10 Jan 2010 Link to this post

    Yey! It works now!
    Thanks!
  9. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 11 Jan 2010 Link to this post

    Super. Glad it worked....Please mark the question as answered.

    / Henrik
Back to Top
DevCraft banner