Class MapperBuilder<TFrom, TTo>
Builds a mapper that maps an object of TFrom type to an object of TTo type.
public class MapperBuilder<TFrom, TTo> : IMapperBuilder
Type Parameters
TFrom
Type to map from.
TTo
Type to map to.
- Inheritance
-
MapperBuilder<TFrom, TTo>
- Implements
- Extension Methods
Properties
DeepCopy
If true, performs deep copy. if default (null), the GetMapperExpression() method does not do deep copy, however the GetMapperExpressionEx() method does.
public bool? DeepCopy { get; set; }
Property Value
- bool?
FromMappingDictionary
Defines member name mapping for source types.
public Dictionary<Type, Dictionary<string, string>>? FromMappingDictionary { get; set; }
Property Value
FromType
Type to map from.
public Type FromType { get; }
Property Value
MappingSchema
Mapping schema.
public MappingSchema MappingSchema { get; set; }
Property Value
MemberMappers
Member mappers.
public List<MemberMapperInfo>? MemberMappers { get; set; }
Property Value
ProcessCrossReferences
If true, processes object cross references. if default (null), the GetMapperExpression() method does not process cross references, however the GetMapperExpressionEx() method does.
public bool? ProcessCrossReferences { get; set; }
Property Value
- bool?
ToMappingDictionary
Defines member name mapping for destination types.
public Dictionary<Type, Dictionary<string, string>>? ToMappingDictionary { get; set; }
Property Value
ToMemberFilter
Filters target members to map.
public Func<MemberAccessor, bool> ToMemberFilter { get; set; }
Property Value
ToType
Type to map to.
public Type ToType { get; }
Property Value
Methods
FromMapping(IReadOnlyDictionary<string, string>)
Defines member name mapping for source types.
public MapperBuilder<TFrom, TTo> FromMapping(IReadOnlyDictionary<string, string> mapping)
Parameters
mapping
IReadOnlyDictionary<string, string>Mapping parameters.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
FromMapping(string, string)
Defines member name mapping for source types.
public MapperBuilder<TFrom, TTo> FromMapping(string memberName, string mapName)
Parameters
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
FromMapping(Type, IReadOnlyDictionary<string, string>)
Defines member name mapping for source types.
public MapperBuilder<TFrom, TTo> FromMapping(Type type, IReadOnlyDictionary<string, string> mapping)
Parameters
type
TypeType to map.
mapping
IReadOnlyDictionary<string, string>Mapping parameters.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
FromMapping(Type, string, string)
Defines member name mapping for source types.
public MapperBuilder<TFrom, TTo> FromMapping(Type type, string memberName, string mapName)
Parameters
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
FromMapping<T>(IReadOnlyDictionary<string, string>)
Defines member name mapping for source types.
public MapperBuilder<TFrom, TTo> FromMapping<T>(IReadOnlyDictionary<string, string> mapping)
Parameters
mapping
IReadOnlyDictionary<string, string>Mapping parameters.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
Type Parameters
T
Type to map.
FromMapping<T>(string, string)
Defines member name mapping for source types.
public MapperBuilder<TFrom, TTo> FromMapping<T>(string memberName, string mapName)
Parameters
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
Type Parameters
T
Type to map.
GetMapper()
Returns a mapper to map an object of TFrom type to an object of TTo type.
public Mapper<TFrom, TTo> GetMapper()
Returns
- 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.
public Expression<Func<TFrom, TTo>> GetMapperExpression()
Returns
- Expression<Func<TFrom, TTo>>
Mapping expression.
GetMapperExpressionEx()
Returns a mapper expression to map an object of TFrom type to an object of TTo type.
public Expression<Func<TFrom, TTo, IDictionary<object, object>?, TTo>> GetMapperExpressionEx()
Returns
- Expression<Func<TFrom, TTo, IDictionary<object, object>, TTo>>
Mapping expression.
MapMember<T>(Expression<Func<TTo, T>>, Expression<Func<TFrom, T>>)
Adds member mapper.
public MapperBuilder<TFrom, TTo> MapMember<T>(Expression<Func<TTo, T>> toMember, Expression<Func<TFrom, T>> setter)
Parameters
toMember
Expression<Func<TTo, T>>Expression that returns a member to map.
setter
Expression<Func<TFrom, T>>Expression to set the member.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
Type Parameters
T
Type of the member to map.
Examples
This example shows how to explicitly convert one value to another.
Mapping(IReadOnlyDictionary<string, string>)
Defines member name mapping for source and destination types.
public MapperBuilder<TFrom, TTo> Mapping(IReadOnlyDictionary<string, string> mapping)
Parameters
mapping
IReadOnlyDictionary<string, string>Mapping parameters.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
Mapping(string, string)
Defines member name mapping for source and destination types.
public MapperBuilder<TFrom, TTo> Mapping(string memberName, string mapName)
Parameters
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
Mapping(Type, IReadOnlyDictionary<string, string>)
Defines member name mapping for source and destination types.
public MapperBuilder<TFrom, TTo> Mapping(Type type, IReadOnlyDictionary<string, string> mapping)
Parameters
type
TypeType to map.
mapping
IReadOnlyDictionary<string, string>Mapping parameters.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
Mapping(Type, string, string)
Defines member name mapping for source and destination types.
public MapperBuilder<TFrom, TTo> Mapping(Type type, string memberName, string mapName)
Parameters
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
Mapping<T>(IReadOnlyDictionary<string, string>)
Defines member name mapping for source and destination types.
public MapperBuilder<TFrom, TTo> Mapping<T>(IReadOnlyDictionary<string, string> mapping)
Parameters
mapping
IReadOnlyDictionary<string, string>Mapping parameters.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
Type Parameters
T
Type to map.
Mapping<T>(string, string)
Defines member name mapping for source and destination types.
public MapperBuilder<TFrom, TTo> Mapping<T>(string memberName, string mapName)
Parameters
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
Type Parameters
T
Type to map.
SetDeepCopy(bool?)
If true, performs deep copy.
public MapperBuilder<TFrom, TTo> SetDeepCopy(bool? deepCopy)
Parameters
deepCopy
bool?If true, performs deep copy.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
SetMappingSchema(MappingSchema)
Sets mapping schema.
public MapperBuilder<TFrom, TTo> SetMappingSchema(MappingSchema schema)
Parameters
schema
MappingSchemaMapping schema to set.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
SetProcessCrossReferences(bool?)
If true, processes object cross references.
public MapperBuilder<TFrom, TTo> SetProcessCrossReferences(bool? doProcess)
Parameters
doProcess
bool?If true, processes object cross references.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
SetToMemberFilter(Func<MemberAccessor, bool>)
Adds a predicate to filter target members to map.
public MapperBuilder<TFrom, TTo> SetToMemberFilter(Func<MemberAccessor, bool> predicate)
Parameters
predicate
Func<MemberAccessor, bool>Predicate to filter members to map.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
ToMapping(IReadOnlyDictionary<string, string>)
Defines member name mapping for destination types.
public MapperBuilder<TFrom, TTo> ToMapping(IReadOnlyDictionary<string, string> mapping)
Parameters
mapping
IReadOnlyDictionary<string, string>Mapping parameters.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
ToMapping(string, string)
Defines member name mapping for destination types.
public MapperBuilder<TFrom, TTo> ToMapping(string memberName, string mapName)
Parameters
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
ToMapping(Type, IReadOnlyDictionary<string, string>)
Defines member name mapping for destination types.
public MapperBuilder<TFrom, TTo> ToMapping(Type type, IReadOnlyDictionary<string, string> mapping)
Parameters
type
TypeType to map.
mapping
IReadOnlyDictionary<string, string>Mapping parameters.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
ToMapping(Type, string, string)
Defines member name mapping for destination types.
public MapperBuilder<TFrom, TTo> ToMapping(Type type, string memberName, string mapName)
Parameters
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
ToMapping<T>(IReadOnlyDictionary<string, string>)
Defines member name mapping for destination types.
public MapperBuilder<TFrom, TTo> ToMapping<T>(IReadOnlyDictionary<string, string> mapping)
Parameters
mapping
IReadOnlyDictionary<string, string>Mapping parameters.
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
Type Parameters
T
Type to map.
ToMapping<T>(string, string)
Defines member name mapping for destination types.
public MapperBuilder<TFrom, TTo> ToMapping<T>(string memberName, string mapName)
Parameters
Returns
- MapperBuilder<TFrom, TTo>
Returns this mapper.
Type Parameters
T
Type to map.