handling unique constaints in Openaccess

4 posts, 0 answers
  1. Brett
    Brett avatar
    2 posts
    Member since:
    Feb 2012

    Posted 21 Aug 2012 Link to this post

    Our entities frequently have multiple candidate keys. We have implemented this in our tables by creating a primary key for the primary key and a unique constraint for each of the candidate keys.  What is the best way of handling these constraints when updating the database through Openaccess?
  2. Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 21 Aug 2012 Link to this post

    Hi Brett,

    You can specify a unique index for your candidate keys. Telerik OpenAccess ORM is able to maintain such a configuration. See this link for details on how to specify such an index.

    I hope this information is helpful for you.
    Feel free to ask if you have any other question.

    Kind regards,
    Ralph
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  3. DevCraft banner
  4. Brett
    Brett avatar
    2 posts
    Member since:
    Feb 2012

    Posted 21 Aug 2012 Link to this post

    Hi Ralph,

    We have already implemented our database with unique indexes on all alternate keys and a unique index on the primary key. I have then generated fromthe database the visual model and the domainservice. I cannot see that the unique indexes were recognized by the Openaccess ORM in either the visual model or the domainservice. Will the ORM check for these constraints or will insert and update statements cause a database error if the unique constraints are not met?

    Regards
    Brett
  5. Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 21 Aug 2012 Link to this post

    Hello Brett,

    Yes, you will get a DuplicateKey exception when a record is inserted that violates the constraint definition. Unfortunately, the information about the indexes is not exposed in the visual designer yet. You can ensure that your indexes were read by opening the .rling file with an xml editor. There you can find the definition of your indexes. 

    Do get back in case you need further assistance.

    Regards,
    Ralph
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
Back to Top