Class EnumToStringConverter<TEnum>
A built-in ValueConverter<TModel, TProvider> that stores an enum as its name
(ToString()) in a text column and parses it back with
Parse<TEnum>(string). It is the ready-made equivalent of a hand-written
ValueConverter<TEnum, string>, so it can be attached with
ValueConverterAttribute or HasConversion and needs no custom class.
public sealed class EnumToStringConverter<TEnum> : ValueConverter<TEnum, string>, IPropertyValueConverter where TEnum : struct, Enum
Type Parameters
TEnumThe enum type stored as its name.
- Inheritance
-
ValueConverter<TEnum, string>EnumToStringConverter<TEnum>
- Implements
- Inherited Members
- Extension Methods
Methods
ConvertFromProvider(string?)
Converts a provider value back to the model representation.
public override TEnum ConvertFromProvider(string? provider)
Parameters
Returns
- TEnum
The model value.
ConvertToProvider(TEnum)
Converts a model value to the provider representation.
public override string? ConvertToProvider(TEnum model)
Parameters
modelTEnumThe model value, or null.
Returns
- string
The provider value.