PropertyBuilder.HasConversion Method

Definition

Overloads

HasConversion(Type, Type, Type)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion(Type, ValueComparer)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion(ValueConverter, ValueComparer, ValueComparer)

Configures the property so that the property value is converted to and from the database using the given ValueConverter.

HasConversion(Type, ValueComparer, ValueComparer)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion(Type)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion(ValueConverter, ValueComparer)

Configures the property so that the property value is converted to and from the database using the given ValueConverter.

HasConversion(ValueConverter)

Configures the property so that the property value is converted to and from the database using the given ValueConverter.

HasConversion(Type, Type)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion<TConversion,TComparer,TProviderComparer>()

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion<TConversion,TComparer>()

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion<TConversion>(ValueComparer, ValueComparer)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion<TConversion>()

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion<TConversion>(ValueComparer)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion(Type, Type, Type)

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type conversionType, Type? comparerType, Type? providerComparerType);

Parameters

conversionType
Type

The type to convert to and from or a type that inherits from ValueConverter.

comparerType
Type

A type that inherits from ValueComparer.

providerComparerType
Type

A type that inherits from ValueComparer to use for the provider values.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 7.0, 8.0, 9.0

HasConversion(Type, ValueComparer)

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type providerClrType, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer valueComparer);
C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type conversionType, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer);

Parameters

providerClrTypeconversionType
Type

The type to convert to and from.

valueComparer
ValueComparer

The comparer to use for values before conversion.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 5.0, 6.0, 7.0, 8.0, 9.0

HasConversion(ValueConverter, ValueComparer, ValueComparer)

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the property so that the property value is converted to and from the database using the given ValueConverter.

C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter? converter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? providerComparer);

Parameters

converter
ValueConverter

The converter to use.

valueComparer
ValueComparer

The comparer to use for values before conversion.

providerComparer
ValueComparer

The comparer to use for the provider values.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 7.0, 8.0, 9.0

HasConversion(Type, ValueComparer, ValueComparer)

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type conversionType, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? providerComparer);

Parameters

conversionType
Type

The type to convert to and from or a type that inherits from ValueConverter.

valueComparer
ValueComparer

The comparer to use for values before conversion.

providerComparer
ValueComparer

The comparer to use for the provider values.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 7.0, 8.0, 9.0

HasConversion(Type)

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type providerClrType);
C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type? conversionType);

Parameters

providerClrTypeconversionType
Type

The type to convert to and from.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

HasConversion(ValueConverter, ValueComparer)

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the property so that the property value is converted to and from the database using the given ValueConverter.

C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter converter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer valueComparer);
C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter? converter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer);

Parameters

converter
ValueConverter

The converter to use.

valueComparer
ValueComparer

The comparer to use for values before conversion.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 5.0, 6.0, 7.0, 8.0, 9.0

HasConversion(ValueConverter)

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the property so that the property value is converted to and from the database using the given ValueConverter.

C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter converter);
C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter? converter);

Parameters

converter
ValueConverter

The converter to use.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

HasConversion(Type, Type)

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type conversionType, Type? comparerType);

Parameters

conversionType
Type

The type to convert to and from or a type that inherits from ValueConverter.

comparerType
Type

A type that inherits from ValueComparer.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 6.0, 7.0, 8.0, 9.0

HasConversion<TConversion,TComparer,TProviderComparer>()

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TConversion,TComparer,TProviderComparer> () where TComparer : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer where TProviderComparer : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer;

Type Parameters

TConversion

The type to convert to and from or a type that inherits from ValueConverter.

TComparer

A type that inherits from ValueComparer.

TProviderComparer

A type that inherits from ValueComparer to use for the provider values.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 7.0, 8.0, 9.0

HasConversion<TConversion,TComparer>()

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TConversion,TComparer> () where TComparer : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer;

Type Parameters

TConversion

The type to convert to and from or a type that inherits from ValueConverter.

TComparer

A type that inherits from ValueComparer.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 6.0, 7.0, 8.0, 9.0

HasConversion<TConversion>(ValueComparer, ValueComparer)

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TConversion> (Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? providerComparer);

Type Parameters

TConversion

The type to convert to and from or a type that inherits from ValueConverter.

Parameters

valueComparer
ValueComparer

The comparer to use for values before conversion.

providerComparer
ValueComparer

The comparer to use for the provider values.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 7.0, 8.0, 9.0

HasConversion<TConversion>()

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TProvider> ();
C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TConversion> ();

Type Parameters

TProvider TConversion

The type to convert to and from or a type that inherits from ValueConverter.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

HasConversion<TConversion>(ValueComparer)

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TProvider> (Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer valueComparer);
C#
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TConversion> (Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer);

Type Parameters

TProvider TConversion

The type to convert to and from or a type that inherits from ValueConverter.

Parameters

valueComparer
ValueComparer

The comparer to use for values before conversion.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 5.0, 6.0, 7.0, 8.0, 9.0