c# - Deserializing a model from an api that contains Enums -
we're developing web application using asp.net mvc 5 c#, i'm having difficulties coming nice solution problem.
we're accessing api has few enums coming across text (i.e. "yes", "no", "notfound", "na") on model i'd have typed enums store in database integer (save little space think) issue comes when we're deserializing response api. in response comes across text (see above) enums expecting integer.
how done? hate asking questions haven't tried web searches hasn't resulted in anything. if needed code please allow me know , i'll update question segments needed. of right model has several typed enums , api returning strings of enum values. way enum texts same homecoming values.
in-case makes difference we're using ef code first 6
you can utilize enum.tryparse convert string enum value
public enum myenum { na yes, no } then
myenum value = myenum.na; enum.tryparse<myenum>(thetextvalue, out value ); c# asp.net-mvc enums ef-code-first deserialization
No comments:
Post a Comment