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

Best practice for defining unique property

3 Answers 68 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
IT
Top achievements
Rank 1
IT asked on 02 Aug 2011, 01:36 AM
If I have a class with a property (other than the key) that I need to be unique, what is the best way to do it? for example, I have a user class with an email property which I want to ensure is unique.

I see this question was asked here: http://www.telerik.com/community/forums/orm/orm-express/unique-key-column.aspx

The response was to manually add the unique constraint to the generated SQL, however this doesn't seem very maintainable.

It's been 7 months... has this been addressed yet, or is there another way I should be doing it?

3 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 04 Aug 2011, 04:09 PM
Hi Aleks,

 Unfortunately due to the low interest in this issue we have pushed it back for further releases and this resulted in no effort being put into that feature.
How important is that for you? If you would like me to I can create a pits issue where you and other people who have faced this issue can vote for improving it. This will certainly have impact and rise the priority of this item.
Please do let me know what you think.

Greetings,
Petar
the Telerik team

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

0
IT
Top achievements
Rank 1
answered on 11 Aug 2011, 07:33 AM
Thanks for your reply.

I gather it's not too important, or more people would be complaining about it...

There are workarounds... you can obviously add code when you create objects to check if a particular property is in use. You can also alter the database schema to achieve the desired affect.

From my perspective, neither are ideal... why make two trips to the database *every time* when you can make one and handle the exception if the constraint is violated; and having to manually alter the schema (or "patch" the output from CreateUpdateDDLScript) seems to break the spirit of that functionality.

To not have support for constraints seems to be a fairly large omission when so many other parts of database functionality are catered for. "db-unique" used to be an option for column definition in the older versions of OpenAccess (admittedly only for index columns), but has since been lost...
0
PetarP
Telerik team
answered on 12 Aug 2011, 04:21 PM
Hello Aleks,

 We have put back this feature for discussion and we will try to reschedule it to be implemented for the upcoming releases.

Regards,
Petar
the Telerik team

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

Tags
Development (API, general questions)
Asked by
IT
Top achievements
Rank 1
Answers by
PetarP
Telerik team
IT
Top achievements
Rank 1
Share this question
or