Table of Contents

Struct TypeMappingManyContext<TSource>

Namespace
LfrlAnvil.Mapping
Assembly
LfrlAnvil.Mapping.dll

A lightweight generic container for a source collection of objects to map.

public readonly struct TypeMappingManyContext<TSource>

Type Parameters

TSource

Source collection's element type.

Inherited Members

Properties

Source

Source collection of objects to map.

public IEnumerable<TSource> Source { get; }

Property Value

IEnumerable<TSource>

TypeMapper

Attached ITypeMapper instance.

public ITypeMapper TypeMapper { get; }

Property Value

ITypeMapper

Methods

To<TDestination>()

Maps the Source collection to a collection with elements of the desired TDestination type using the attached TypeMapper instance.

[Pure]
public IEnumerable<TDestination> To<TDestination>()

Returns

IEnumerable<TDestination>

Source collection mapped to collection with elements of the TDestination type.

Type Parameters

TDestination

Desired destination collection's element type.

Exceptions

UndefinedTypeMappingException

When mapping from TSource to TDestination is not defined.

TryTo<TDestination>(out IEnumerable<TDestination>)

Attempts to map the Source collection to a collection with elements of the desired TDestination type using the attached TypeMapper instance.

public bool TryTo<TDestination>(out IEnumerable<TDestination> result)

Parameters

result IEnumerable<TDestination>

out parameter that returns Source collection mapped to collection with elements of the TDestination type if mapping was successful.

Returns

bool

true when mapping was successful, otherwise false.

Type Parameters

TDestination

Desired destination collection's element type.