ValueConverter<TModel,TProvider> Class

Definition

Defines conversions from an object of one type in a model to an object of the same or different type in the store.

public class ValueConverter<TModel,TProvider> : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter
type ValueConverter<'Model, 'Provider> = class
    inherit ValueConverter
Public Class ValueConverter(Of TModel, TProvider)
Inherits ValueConverter

Type Parameters

TModel
TProvider
Inheritance
ValueConverter<TModel,TProvider>
Derived

Remarks

See EF Core value converters for more information.

Constructors

ValueConverter<TModel,TProvider>(Expression<Func<TModel,TProvider>>, Expression<Func<TProvider,TModel>>, Boolean, ConverterMappingHints)

Initializes a new instance of the ValueConverter<TModel,TProvider> class, allowing conversion of nulls.

Warning: this is currently an internal API since converting nulls to and from the database can lead to broken queries and other issues. See https://github.com/dotnet/efcore/issues/26230 for more information.

ValueConverter<TModel,TProvider>(Expression<Func<TModel,TProvider>>, Expression<Func<TProvider,TModel>>, ConverterMappingHints)

Initializes a new instance of the ValueConverter<TModel,TProvider> class.

Properties

ConvertFromProvider

Gets the function to convert objects when reading data from the store, setup to handle nulls, boxing, and non-exact matches of simple types.

ConvertFromProviderExpression

Gets the expression to convert objects when reading data from the store, exactly as supplied and may not handle nulls, boxing, and non-exact matches of simple types.

ConvertsNulls

If true, then the nulls will be passed to the converter for conversion. Otherwise null values always remain null.

By default, value converters do not handle nulls so that a value converter for a non-nullable property (such as a primary key) can be used for correlated nullable properties, such as any corresponding foreign key properties.

(Inherited from ValueConverter)
ConvertToProvider

Gets the function to convert objects when writing data to the store, setup to handle nulls, boxing, and non-exact matches of simple types.

ConvertToProviderExpression

Gets the expression to convert objects when writing data to the store, exactly as supplied and may not handle nulls, boxing, and non-exact matches of simple types.

MappingHints

Hints that can be used by the ITypeMappingSource to create data types with appropriate facets for the converted data.

(Inherited from ValueConverter)
ModelClrType

The CLR type used in the EF model.

ProviderClrType

The CLR type used when reading and writing from the store.

Methods

ComposeWith(ValueConverter)

Composes another ValueConverter instance with this one such that the result of the first conversion is used as the input to the second conversion.

(Inherited from ValueConverter)

Applies to