Page 1 of 1

How do I return int instead of enum value?

Posted: Thu 16 May 2019 23:16
by RaminNoodle
Hello,
One of my entities has a column defined as an enum. When I store the value in a database it stores as int, however when I retrieve the value EF automatically converts it into the enums string value. I would like to only return back the integer instead of the friendly name so my client application can handle casting.

Iv looked into HasConvertion however I cannot figure out how to return an int instead of the enum string value.

Re: How do I return int instead of enum value?

Posted: Fri 17 May 2019 14:31
by Shalex
RaminNoodle wrote: Thu 16 May 2019 23:16One of my entities has a column defined as an enum. When I store the value in a database it stores as int, however when I retrieve the value EF automatically converts it into the enums string value.
Sorry, the issue is not clear. If you need to retrieve int value, please set the type of your class property to int.