This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi,
I have read many post about mapping enumeration but none of them have an answer to my question.
I have a table named "Priority" with a PrimaryKey "Id" and a column "Description". I have another table named "Note" with a PrimaryKey "Id", a column "Texte" and a column "PriorityId" with a reference to the table "Priority".
I have created an Enum with two differents values: "Low", "Hight".
When I use the "Note" entity, I want to code like this: If Note.Priority = Priority.Low Then ....
The problem is that I don't know how to map an Enum in this manner.
I know that I must create a UserDefinedType with a link to my enumeration but after that, it doesn't work to associate the PrimaryKey of the table "Priority" to the enum; it just work for a field that is not a Primarykey like an ExternalId.
Have you a solution?
Thank you. |
|
|
Note.Priority is an association. It will return an entity of type Priority, not an enum. |
|
|
It is possible to mark the Id of Priority with the enum? Note.Priority.Id where Id is the Enum. |
|
|
It isn't possible using the designer. It might be possible to do it in a hand-coded entity class, but it's not a scenario that we test with. Sorry. What you can do is add a property through the partial class that surfaces the integer Id as an enum: partial class Priority { Then you can write: if (note.Priority.PriorityLevel == PriorityLevel.Low) { ... } |
|
|
Thank you very, that is exactly what I want. |
|