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 and examples.

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 GitHub issue #26230 for more information and examples.

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.

ConvertFromProviderTyped

Gets the function to convert objects when reading data from the store.

ConvertsNulls

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

(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.

ConvertToProviderTyped

Gets the function to convert objects when writing data to the store.

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