Class MapperBuilder<TFrom, TTo>
Builds a mapper that maps an object of TFrom type to an object of TTo type.
Inheritance
Implements
Namespace: LinqToDB.Tools.Mapper
Assembly: linq2db.Tools.dll
Syntax
public class MapperBuilder<TFrom, TTo> : object, IMapperBuilder
Type Parameters
Name | Description |
---|---|
TFrom | Type to map from. |
TTo | Type to map to. |
Properties
| Improve this Doc View SourceDeepCopy
If true, performs deep copy. if default (null), the GetMapperExpression() method does not do deep copy, however the GetMapperExpressionEx() method does.
Declaration
public bool? DeepCopy { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Boolean> |
FromMappingDictionary
Defines member name mapping for source types.
Declaration
public Dictionary<Type, Dictionary<string, string>>? FromMappingDictionary { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<Dictionary<Type, Dictionary<System.String, System.String>>> |
FromType
Type to map from.
Declaration
public Type FromType { get; }
Property Value
Type | Description |
---|---|
Type |
MappingSchema
Mapping schema.
Declaration
public MappingSchema MappingSchema { get; set; }
Property Value
Type | Description |
---|---|
MappingSchema |
MemberMappers
Member mappers.
Declaration
public List<MemberMapperInfo>? MemberMappers { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<List<MemberMapperInfo>> |
ProcessCrossReferences
If true, processes object cross references. if default (null), the GetMapperExpression() method does not process cross references, however the GetMapperExpressionEx() method does.
Declaration
public bool? ProcessCrossReferences { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Boolean> |
ToMappingDictionary
Defines member name mapping for destination types.
Declaration
public Dictionary<Type, Dictionary<string, string>>? ToMappingDictionary { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<Dictionary<Type, Dictionary<System.String, System.String>>> |
ToMemberFilter
Filters target members to map.
Declaration
public Func<MemberAccessor, bool> ToMemberFilter { get; set; }
Property Value
Type | Description |
---|---|
Func<MemberAccessor, System.Boolean> |
ToType
Type to map to.
Declaration
public Type ToType { get; }
Property Value
Type | Description |
---|---|
Type |
Methods
| Improve this Doc View SourceFromMapping(IReadOnlyDictionary<String, String>)
Defines member name mapping for source types.
Declaration
public MapperBuilder<TFrom, TTo> FromMapping(IReadOnlyDictionary<string, string> mapping)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyDictionary<System.String, System.String> | mapping | Mapping parameters. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
FromMapping(String, String)
Defines member name mapping for source types.
Declaration
public MapperBuilder<TFrom, TTo> FromMapping(string memberName, string mapName)
Parameters
Type | Name | Description |
---|---|---|
System.String | memberName | Type member name. |
System.String | mapName | Mapping name. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
FromMapping(Type, IReadOnlyDictionary<String, String>)
Defines member name mapping for source types.
Declaration
public MapperBuilder<TFrom, TTo> FromMapping(Type type, IReadOnlyDictionary<string, string> mapping)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type to map. |
IReadOnlyDictionary<System.String, System.String> | mapping | Mapping parameters. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
FromMapping(Type, String, String)
Defines member name mapping for source types.
Declaration
public MapperBuilder<TFrom, TTo> FromMapping(Type type, string memberName, string mapName)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type to map. |
System.String | memberName | Type member name. |
System.String | mapName | Mapping name. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
FromMapping<T>(IReadOnlyDictionary<String, String>)
Defines member name mapping for source types.
Declaration
public MapperBuilder<TFrom, TTo> FromMapping<T>(IReadOnlyDictionary<string, string> mapping)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyDictionary<System.String, System.String> | mapping | Mapping parameters. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
Type Parameters
Name | Description |
---|---|
T | Type to map. |
FromMapping<T>(String, String)
Defines member name mapping for source types.
Declaration
public MapperBuilder<TFrom, TTo> FromMapping<T>(string memberName, string mapName)
Parameters
Type | Name | Description |
---|---|---|
System.String | memberName | Type member name. |
System.String | mapName | Mapping name. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
Type Parameters
Name | Description |
---|---|
T | Type to map. |
GetMapper()
Returns a mapper to map an object of TFrom type to an object of TTo type.
Declaration
public Mapper<TFrom, TTo> GetMapper()
Returns
Type | Description |
---|---|
Mapper<TFrom, TTo> | Mapping expression. |
GetMapperExpression()
Returns a mapper expression to map an object of TFrom type to an object of TTo type. Returned expression is compatible to IQueryable.
Declaration
public Expression<Func<TFrom, TTo>> GetMapperExpression()
Returns
Type | Description |
---|---|
Expression<Func<TFrom, TTo>> | Mapping expression. |
GetMapperExpressionEx()
Returns a mapper expression to map an object of TFrom type to an object of TTo type.
Declaration
public Expression<Func<TFrom, TTo, IDictionary<object, object>?, TTo>> GetMapperExpressionEx()
Returns
Type | Description |
---|---|
Expression<Func<TFrom, TTo, System.Nullable<IDictionary<System.Object, System.Object>>, TTo>> | Mapping expression. |
MapMember<T>(Expression<Func<TTo, T>>, Expression<Func<TFrom, T>>)
Adds member mapper.
Declaration
public MapperBuilder<TFrom, TTo> MapMember<T>(Expression<Func<TTo, T>> toMember, Expression<Func<TFrom, T>> setter)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TTo, T>> | toMember | Expression that returns a member to map. |
Expression<Func<TFrom, T>> | setter | Expression to set the member. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
Type Parameters
Name | Description |
---|---|
T | Type of the member to map. |
Examples
This example shows how to explicitly convert one value to another.
| Improve this Doc View SourceMapping(IReadOnlyDictionary<String, String>)
Defines member name mapping for source and destination types.
Declaration
public MapperBuilder<TFrom, TTo> Mapping(IReadOnlyDictionary<string, string> mapping)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyDictionary<System.String, System.String> | mapping | Mapping parameters. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
Mapping(String, String)
Defines member name mapping for source and destination types.
Declaration
public MapperBuilder<TFrom, TTo> Mapping(string memberName, string mapName)
Parameters
Type | Name | Description |
---|---|---|
System.String | memberName | Type member name. |
System.String | mapName | Mapping name. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
Mapping(Type, IReadOnlyDictionary<String, String>)
Defines member name mapping for source and destination types.
Declaration
public MapperBuilder<TFrom, TTo> Mapping(Type type, IReadOnlyDictionary<string, string> mapping)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type to map. |
IReadOnlyDictionary<System.String, System.String> | mapping | Mapping parameters. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
Mapping(Type, String, String)
Defines member name mapping for source and destination types.
Declaration
public MapperBuilder<TFrom, TTo> Mapping(Type type, string memberName, string mapName)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type to map. |
System.String | memberName | Type member name. |
System.String | mapName | Mapping name. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
Mapping<T>(IReadOnlyDictionary<String, String>)
Defines member name mapping for source and destination types.
Declaration
public MapperBuilder<TFrom, TTo> Mapping<T>(IReadOnlyDictionary<string, string> mapping)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyDictionary<System.String, System.String> | mapping | Mapping parameters. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
Type Parameters
Name | Description |
---|---|
T | Type to map. |
Mapping<T>(String, String)
Defines member name mapping for source and destination types.
Declaration
public MapperBuilder<TFrom, TTo> Mapping<T>(string memberName, string mapName)
Parameters
Type | Name | Description |
---|---|---|
System.String | memberName | Type member name. |
System.String | mapName | Mapping name. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
Type Parameters
Name | Description |
---|---|
T | Type to map. |
SetDeepCopy(Nullable<Boolean>)
If true, performs deep copy.
Declaration
public MapperBuilder<TFrom, TTo> SetDeepCopy(bool? deepCopy)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Boolean> | deepCopy | If true, performs deep copy. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
SetMappingSchema(MappingSchema)
Sets mapping schema.
Declaration
public MapperBuilder<TFrom, TTo> SetMappingSchema(MappingSchema schema)
Parameters
Type | Name | Description |
---|---|---|
MappingSchema | schema | Mapping schema to set. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
SetProcessCrossReferences(Nullable<Boolean>)
If true, processes object cross references.
Declaration
public MapperBuilder<TFrom, TTo> SetProcessCrossReferences(bool? doProcess)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Boolean> | doProcess | If true, processes object cross references. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
SetToMemberFilter(Func<MemberAccessor, Boolean>)
Adds a predicate to filter target members to map.
Declaration
public MapperBuilder<TFrom, TTo> SetToMemberFilter(Func<MemberAccessor, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
Func<MemberAccessor, System.Boolean> | predicate | Predicate to filter members to map. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
ToMapping(IReadOnlyDictionary<String, String>)
Defines member name mapping for destination types.
Declaration
public MapperBuilder<TFrom, TTo> ToMapping(IReadOnlyDictionary<string, string> mapping)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyDictionary<System.String, System.String> | mapping | Mapping parameters. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
ToMapping(String, String)
Defines member name mapping for destination types.
Declaration
public MapperBuilder<TFrom, TTo> ToMapping(string memberName, string mapName)
Parameters
Type | Name | Description |
---|---|---|
System.String | memberName | Type member name. |
System.String | mapName | Mapping name. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
ToMapping(Type, IReadOnlyDictionary<String, String>)
Defines member name mapping for destination types.
Declaration
public MapperBuilder<TFrom, TTo> ToMapping(Type type, IReadOnlyDictionary<string, string> mapping)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type to map. |
IReadOnlyDictionary<System.String, System.String> | mapping | Mapping parameters. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
ToMapping(Type, String, String)
Defines member name mapping for destination types.
Declaration
public MapperBuilder<TFrom, TTo> ToMapping(Type type, string memberName, string mapName)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type to map. |
System.String | memberName | Type member name. |
System.String | mapName | Mapping name. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
ToMapping<T>(IReadOnlyDictionary<String, String>)
Defines member name mapping for destination types.
Declaration
public MapperBuilder<TFrom, TTo> ToMapping<T>(IReadOnlyDictionary<string, string> mapping)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyDictionary<System.String, System.String> | mapping | Mapping parameters. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
Type Parameters
Name | Description |
---|---|
T | Type to map. |
ToMapping<T>(String, String)
Defines member name mapping for destination types.
Declaration
public MapperBuilder<TFrom, TTo> ToMapping<T>(string memberName, string mapName)
Parameters
Type | Name | Description |
---|---|---|
System.String | memberName | Type member name. |
System.String | mapName | Mapping name. |
Returns
Type | Description |
---|---|
MapperBuilder<TFrom, TTo> | Returns this mapper. |
Type Parameters
Name | Description |
---|---|
T | Type to map. |
Explicit Interface Implementations
| Improve this Doc View SourceIMapperBuilder.GetMapperLambdaExpression()
Declaration
LambdaExpression IMapperBuilder.GetMapperLambdaExpression()
Returns
Type | Description |
---|---|
LambdaExpression |
IMapperBuilder.GetMapperLambdaExpressionEx()
Declaration
LambdaExpression IMapperBuilder.GetMapperLambdaExpressionEx()
Returns
Type | Description |
---|---|
LambdaExpression |