Best practice for defining unique property

4 posts, 0 answers
  1. IT
    IT avatar
    41 posts
    Member since:
    Jan 2010

    Posted 01 Aug 2011 Link to this post

    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?
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 04 Aug 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. IT
    IT avatar
    41 posts
    Member since:
    Jan 2010

    Posted 11 Aug 2011 Link to this post

    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...
  5. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 12 Aug 2011 Link to this post

    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 >>

Back to Top