I have an entity class that has a property with an underlying db column of datatype Int, however in reality I want this property to be an Enum. Is there any way to specify that this property returns an Enum?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Indirectly, like so.
Personally, I leave the storage int public (for example as
DbFoo, where the enum property isFoo) – that way I can still write lambdas against the column for execution at the DB, for example:If you don’t expose the storage value, you can’t do this as cleanly. You could equally leave it internal, and have some methods in the context to do the filtering… here’s one I wrote earlier today:
where
User.UserTypeAdminis my internal constant. In this case, I couldn’t use a discriminated subclass, as it was interfering with ADO.NET Data Services.