Table of Contents

Class Converter

Namespace
LinqToDB.Common
Assembly
linq2db.dll

Type conversion manager.

public static class Converter
Inheritance
Converter

Methods

ChangeType(object?, Type, MappingSchema?, ConversionType)

Converts value to toConvertType type.

public static object? ChangeType(object? value, Type toConvertType, MappingSchema? mappingSchema = null, ConversionType conversionType = ConversionType.Common)

Parameters

value object

Value to convert.

toConvertType Type

Target conversion type.

mappingSchema MappingSchema

Optional mapping schema.

conversionType ConversionType

Conversion type. See ConversionType for details.

Returns

object

Converted value.

ChangeTypeTo<T>(object?, MappingSchema?, ConversionType)

Converts value to T type.

public static T ChangeTypeTo<T>(object? value, MappingSchema? mappingSchema = null, ConversionType conversionType = ConversionType.Common)

Parameters

value object

Value to convert.

mappingSchema MappingSchema

Optional mapping schema.

conversionType ConversionType

Conversion type. See ConversionType for details.

Returns

T

Converted value.

Type Parameters

T

Target conversion type.

GetDefaultMappingFromEnumType(MappingSchema, Type)

Returns type, to which provided enumeration values should be mapped.

public static Type? GetDefaultMappingFromEnumType(MappingSchema mappingSchema, Type enumType)

Parameters

mappingSchema MappingSchema

Current mapping schema

enumType Type

Enumeration type.

Returns

Type

Underlying mapping type.

SetConverter<TFrom, TTo>(Expression<Func<TFrom, TTo>>)

Sets custom converter from TFrom to TTo type.

public static void SetConverter<TFrom, TTo>(Expression<Func<TFrom, TTo>> expr)

Parameters

expr Expression<Func<TFrom, TTo>>

Converter expression.

Type Parameters

TFrom

Source conversion type.

TTo

Target conversion type.