-
-
Notifications
You must be signed in to change notification settings - Fork 10
Storing and retrieval of enum values not working. #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you explain further? Same thing happens for example when I save to a normal database. An enum saves as an integer because it is an integer. When I read back that integer, I have to know to convert it back to an enum. Just an example on C# scaffolded entity model of mine: [NotMapped]
public Status StatusEnum
{
get
{
Status enumstat = (Status)Enum.ToObject(typeof(Status), StatusDbint);
return enumstat;
}
set
{
StatusDbint = (int)value;
}
}
[Column("Status_DBInt")]
public int StatusDbint { get; set; } This is my lazy man way of doing it lol, but the StatusDbint is the integer it saves to the database, as where I have my non mapped statusEnum that converts and sets that int properly. Just showing this to see if we're on the same page, or maybe I'm misunderstanding, or maybe you've had different entity framework experiences that I'm not aware of :) |
Will re-open the issue if we discover this is an issue, but from my current understanding, this is by design. |
It has been my experience that a all databases can read back what they wrote. The underlying implementation should not have any effect on the read/write process. This is encapsulation. I agree that integers are a good choice for the underlying implementation. They can even handle [Flags] enum types. Entity Framework handles enums as I have described. |
@yueyinqiu We need to test this with the new serializer. I Haven't checked out your unit tests yet, but was just thinking about this. |
When the database saves an enum value it saves it as an integer. This is fine, but when retrieving the data it can't turn the integer back into an enum value.
The text was updated successfully, but these errors were encountered: