Share via


ValueConverter<TModel,TProvider> Constructors

Definition

Overloads

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

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

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.

public ValueConverter (System.Linq.Expressions.Expression<Func<TModel,TProvider>> convertToProviderExpression, System.Linq.Expressions.Expression<Func<TProvider,TModel>> convertFromProviderExpression, Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = default);
public ValueConverter (System.Linq.Expressions.Expression<Func<TModel,TProvider>> convertToProviderExpression, System.Linq.Expressions.Expression<Func<TProvider,TModel>> convertFromProviderExpression, Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints? mappingHints = default);
new Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<'Model, 'Provider> : System.Linq.Expressions.Expression<Func<'Model, 'Provider>> * System.Linq.Expressions.Expression<Func<'Provider, 'Model>> * Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints -> Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<'Model, 'Provider>
Public Sub New (convertToProviderExpression As Expression(Of Func(Of TModel, TProvider)), convertFromProviderExpression As Expression(Of Func(Of TProvider, TModel)), Optional mappingHints As ConverterMappingHints = Nothing)

Parameters

convertToProviderExpression
Expression<Func<TModel,TProvider>>

An expression to convert objects when writing data to the store.

convertFromProviderExpression
Expression<Func<TProvider,TModel>>

An expression to convert objects when reading data from the store.

mappingHints
ConverterMappingHints

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

Remarks

See EF Core value converters for more information and examples.

Applies to

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.

[Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkInternal]
public ValueConverter (System.Linq.Expressions.Expression<Func<TModel,TProvider>> convertToProviderExpression, System.Linq.Expressions.Expression<Func<TProvider,TModel>> convertFromProviderExpression, bool convertsNulls, Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints? mappingHints = default);
[<Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkInternal>]
new Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<'Model, 'Provider> : System.Linq.Expressions.Expression<Func<'Model, 'Provider>> * System.Linq.Expressions.Expression<Func<'Provider, 'Model>> * bool * Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints -> Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<'Model, 'Provider>
Public Sub New (convertToProviderExpression As Expression(Of Func(Of TModel, TProvider)), convertFromProviderExpression As Expression(Of Func(Of TProvider, TModel)), convertsNulls As Boolean, Optional mappingHints As ConverterMappingHints = Nothing)

Parameters

convertToProviderExpression
Expression<Func<TModel,TProvider>>

An expression to convert objects when writing data to the store.

convertFromProviderExpression
Expression<Func<TProvider,TModel>>

An expression to convert objects when reading data from the store.

convertsNulls
Boolean

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

mappingHints
ConverterMappingHints

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

Attributes

Remarks

See EF Core value converters for more information and examples.

Applies to