How do I return int instead of enum value?

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
RaminNoodle
Posts: 1
Joined: Thu 16 May 2019 23:09

How do I return int instead of enum value?

Post by RaminNoodle » Thu 16 May 2019 23:16

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Fri 17 May 2019 14:31

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.

Post Reply