Class ValueConverter<TModel, TProvider>
Base class for a strongly typed property value converter. Subclasses override the typed ConvertToProvider(TModel?) and ConvertFromProvider(TProvider?) methods; the IPropertyValueConverter members are implemented here through a cached typed invoker so value types are not boxed on every row.
public abstract class ValueConverter<TModel, TProvider> : IPropertyValueConverter
Type Parameters
TModelThe CLR model type of the property.
TProviderThe provider-side type stored in the column.
- Inheritance
-
ValueConverter<TModel, TProvider>
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
ValueConverter()
Initializes the converter and caches its typed invokers.
protected ValueConverter()
Properties
ConvertsNulls
Whether a SQL NULL is passed through the converter instead of being mapped to a
null model value. Defaults to false.
public virtual bool ConvertsNulls { get; }
Property Value
ProviderType
The provider-side type produced by ConvertToProvider(object?) and consumed by ConvertFromProvider(object?). The reader uses it to select the typed accessor and the write path uses it to type the bound parameter.
public Type ProviderType { get; }
Property Value
Methods
ConvertFromProvider(TProvider?)
Converts a provider value back to the model representation.
public abstract TModel? ConvertFromProvider(TProvider? provider)
Parameters
providerTProviderThe provider value, or null.
Returns
- TModel
The model value.
ConvertToProvider(TModel?)
Converts a model value to the provider representation.
public abstract TProvider? ConvertToProvider(TModel? model)
Parameters
modelTModelThe model value, or null.
Returns
- TProvider
The provider value.