PropertyBuilder.HasConversion Method (Microsoft.EntityFrameworkCore.Metadata.Builders) (2024)

Share via

  • Reference

Definition

Namespace:
Microsoft.EntityFrameworkCore.Metadata.Builders
Assembly:
Microsoft.EntityFrameworkCore.dll
Package:
Microsoft.EntityFrameworkCore v7.0.0
Package:
Microsoft.EntityFrameworkCore v8.0.0
Package:
Microsoft.EntityFrameworkCore v5.0.0
Package:
Microsoft.EntityFrameworkCore v6.0.0
Package:
Microsoft.EntityFrameworkCore v2.1.11
Package:
Microsoft.EntityFrameworkCore v2.2.6
Package:
Microsoft.EntityFrameworkCore v3.0.0
Package:
Microsoft.EntityFrameworkCore v3.1.0

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

HasConversion(Type, Type, Type)

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

HasConversion(Type, ValueComparer)

Configures the property so that the property value is converted beforewriting 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 databaseusing the given ValueConverter.

HasConversion(Type, ValueComparer, ValueComparer)

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

HasConversion(Type)

Configures the property so that the property value is converted beforewriting 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 databaseusing the given ValueConverter.

HasConversion(ValueConverter)

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

HasConversion(Type, Type)

Configures the property so that the property value is converted beforewriting 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 beforewriting to the database and converted back when reading from the database.

HasConversion<TConversion,TComparer>()

Configures the property so that the property value is converted beforewriting 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 beforewriting to the database and converted back when reading from the database.

HasConversion<TConversion>()

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

HasConversion<TConversion>(ValueComparer)

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

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type conversionType, Type? comparerType, Type? providerComparerType);
abstract member HasConversion : Type * Type * Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilderoverride this.HasConversion : Type * Type * Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasConversion (conversionType As Type, comparerType As Type, providerComparerType As Type) As PropertyBuilder

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

PropertyBuilder

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

Applies to

HasConversion(Type, ValueComparer)

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type providerClrType, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer valueComparer);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type conversionType, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer);
abstract member HasConversion : Type * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilderoverride this.HasConversion : Type * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
abstract member HasConversion : Type * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilderoverride this.HasConversion : Type * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasConversion (providerClrType As Type, valueComparer As ValueComparer) As PropertyBuilder
Public Overridable Function HasConversion (conversionType As Type, valueComparer As ValueComparer) As PropertyBuilder

Parameters

providerClrTypeconversionType
Type

The type to convert to and from.

valueComparer
ValueComparer

The comparer to use for values before conversion.

Returns

PropertyBuilder

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

Applies to

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter? converter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? providerComparer);
abstract member HasConversion : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilderoverride this.HasConversion : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasConversion (converter As ValueConverter, valueComparer As ValueComparer, providerComparer As ValueComparer) As PropertyBuilder

Parameters

converter
ValueConverter

The converter to use.

providerComparer
ValueComparer

The comparer to use for the provider values.

Returns

PropertyBuilder

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

Applies to

HasConversion(Type, ValueComparer, ValueComparer)

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type conversionType, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? providerComparer);
abstract member HasConversion : Type * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilderoverride this.HasConversion : Type * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasConversion (conversionType As Type, valueComparer As ValueComparer, providerComparer As ValueComparer) As PropertyBuilder

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

PropertyBuilder

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

Applies to

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type providerClrType);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type? conversionType);
abstract member HasConversion : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilderoverride this.HasConversion : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
abstract member HasConversion : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilderoverride this.HasConversion : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasConversion (providerClrType As Type) As PropertyBuilder
Public Overridable Function HasConversion (conversionType As Type) As PropertyBuilder

Parameters

providerClrTypeconversionType
Type

The type to convert to and from.

Returns

PropertyBuilder

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

Applies to

HasConversion(ValueConverter, ValueComparer)

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter converter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer valueComparer);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter? converter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer);
abstract member HasConversion : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilderoverride this.HasConversion : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasConversion (converter As ValueConverter, valueComparer As ValueComparer) As PropertyBuilder

Parameters

converter
ValueConverter

The converter to use.

valueComparer
ValueComparer

The comparer to use for values before conversion.

Returns

PropertyBuilder

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

Applies to

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter converter);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter? converter);
abstract member HasConversion : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilderoverride this.HasConversion : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasConversion (converter As ValueConverter) As PropertyBuilder

Parameters

converter
ValueConverter

The converter to use.

Returns

PropertyBuilder

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

Applies to

HasConversion(Type, Type)

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion (Type conversionType, Type? comparerType);
abstract member HasConversion : Type * Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilderoverride this.HasConversion : Type * Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasConversion (conversionType As Type, comparerType As Type) As PropertyBuilder

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

PropertyBuilder

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

Applies to

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TConversion,TComparer,TProviderComparer> () where TComparer : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer where TProviderComparer : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer;
abstract member HasConversion : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder (requires 'Comparer :> Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer and 'ProviderComparer :> Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer)override this.HasConversion : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder (requires 'Comparer :> Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer and 'ProviderComparer :> Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer)
Public Overridable Function HasConversion(Of TConversion, TComparer, TProviderComparer) () As PropertyBuilder

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

PropertyBuilder

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

Applies to

HasConversion<TConversion,TComparer>()

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TConversion,TComparer> () where TComparer : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer;
abstract member HasConversion : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder (requires 'Comparer :> Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer)override this.HasConversion : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder (requires 'Comparer :> Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer)
Public Overridable Function HasConversion(Of TConversion, TComparer) () As PropertyBuilder

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

PropertyBuilder

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

Applies to

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TConversion> (Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? providerComparer);
abstract member HasConversion : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilderoverride this.HasConversion : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasConversion(Of TConversion) (valueComparer As ValueComparer, providerComparer As ValueComparer) As PropertyBuilder

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

PropertyBuilder

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

Applies to

HasConversion<TConversion>()

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TProvider> ();
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TConversion> ();
abstract member HasConversion : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilderoverride this.HasConversion : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasConversion(Of TProvider) () As PropertyBuilder
Public Overridable Function HasConversion(Of TConversion) () As PropertyBuilder

Type Parameters

TProvider TConversion

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

Returns

PropertyBuilder

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

Applies to

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TProvider> (Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer valueComparer);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasConversion<TConversion> (Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer);
abstract member HasConversion : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilderoverride this.HasConversion : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasConversion(Of TProvider) (valueComparer As ValueComparer) As PropertyBuilder
Public Overridable Function HasConversion(Of TConversion) (valueComparer As ValueComparer) As PropertyBuilder

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

PropertyBuilder

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

Applies to

Feedback

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback.

Submit and view feedback for

PropertyBuilder.HasConversion Method (Microsoft.EntityFrameworkCore.Metadata.Builders) (2024)
Top Articles
Latest Posts
Article information

Author: Arielle Torp

Last Updated:

Views: 6502

Rating: 4 / 5 (61 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Arielle Torp

Birthday: 1997-09-20

Address: 87313 Erdman Vista, North Dustinborough, WA 37563

Phone: +97216742823598

Job: Central Technology Officer

Hobby: Taekwondo, Macrame, Foreign language learning, Kite flying, Cooking, Skiing, Computer programming

Introduction: My name is Arielle Torp, I am a comfortable, kind, zealous, lovely, jolly, colorful, adventurous person who loves writing and wants to share my knowledge and understanding with you.