Table of Contents

Class BoolToTwoValuesConverter<TProvider>

Namespace
Microsoft.EntityFrameworkCore.Storage.ValueConversion
Assembly
Microsoft.EntityFrameworkCore.dll

Converts bool values to and from two different values.

public class BoolToTwoValuesConverter<TProvider> : ValueConverter<bool, TProvider>

Type Parameters

TProvider
Inheritance
ValueConverter<bool, TProvider>
BoolToTwoValuesConverter<TProvider>
Derived
Inherited Members

Remarks

See EF Core value converters for more information and examples.

Constructors

BoolToTwoValuesConverter(TProvider, TProvider, Expression<Func<TProvider, bool>>?, ConverterMappingHints?)

Creates a new instance of this converter that will convert a false false to one value and a true to another.

public BoolToTwoValuesConverter(TProvider falseValue, TProvider trueValue, Expression<Func<TProvider, bool>>? fromProvider = null, ConverterMappingHints? mappingHints = null)

Parameters

falseValue TProvider

The value to convert to for false.

trueValue TProvider

The value to convert to for true.

fromProvider Expression<Func<TProvider, bool>>

Optional custom translator from store.

mappingHints ConverterMappingHints

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

Remarks

Use BoolToZeroOneConverter<TProvider> for converting a bool to zero/one.

See EF Core value converters for more information and examples.