Condividi tramite


ValueConverter 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 abstract class ValueConverter
type ValueConverter = class
Public MustInherit Class ValueConverter
Inheritance
ValueConverter
Derived

Remarks

See EF Core value converters for more information and examples.

Constructors

ValueConverter(LambdaExpression, LambdaExpression, Boolean, ConverterMappingHints)

Initializes a new instance of the ValueConverter 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(LambdaExpression, LambdaExpression, ConverterMappingHints)

Initializes a new instance of the ValueConverter class.

Properties

ConstructorExpression

The expression representing construction of this object.

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.

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.

ModelClrType

The CLR type used in the EF model.

ProviderClrType

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

Methods

CheckTypeSupported(Type, Type, Type[])

Checks that the type used with a value converter is supported by that converter and throws if not.

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.

Applies to