This is a migrated thread and some comments may be shown as answers.

handling unique constaints in Openaccess

3 Answers 90 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brett
Top achievements
Rank 1
Brett asked on 21 Aug 2012, 07:10 AM
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?

3 Answers, 1 is accepted

Sort by
0
Ralph Waldenmaier
Telerik team
answered on 21 Aug 2012, 10:29 AM
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!
0
Brett
Top achievements
Rank 1
answered on 21 Aug 2012, 11:07 AM
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
0
Ralph Waldenmaier
Telerik team
answered on 21 Aug 2012, 01:10 PM
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!
Tags
General Discussions
Asked by
Brett
Top achievements
Rank 1
Answers by
Ralph Waldenmaier
Telerik team
Brett
Top achievements
Rank 1
Share this question
or