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

Non-Integer Primary Key ID Field

1 Answer 91 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.
Brian
Top achievements
Rank 1
Brian asked on 09 Feb 2011, 09:07 PM
Does OpenAccess ORM support ID fields that are not integer types (i.e. not short, int, long)?

The reason I ask is that there are some tables with a LOT of additions and deletions over time, so you eventually hit the int.maxValue limit and need to reset the seed through database administration.  There are some tables where we have a natural key that is a nvarchar string, for example.  Suppose the table stores website URL links and the associated IP address of the host.  Ideally, in that case, I would want:
  • An entity model with a URL:String & IP:String field that map to nvarchar and varchar repsectively in the database.
  • URL is set as the primary key, and OpenAcess does not try to go ahead and create its own integer based ID field as it does today (which results in the same problem)
This not only saves database space for a very large table, but also makes management easier.  I agree that for moderately sized tables, an integer based ID is the best way to go, and it is what I do.

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 10 Feb 2011, 02:28 PM
Hi Brian Womack,

There should be no problem to use a string as primary key. You only need to change the Identity setting (from the Properties pane) of the URL property to true and disable it for all other properties. Additionally, the Identity Mechanism of the class should be set to Default. I hope that helps.

Kind regards,
Alexander
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Tags
Development (API, general questions)
Asked by
Brian
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or