Table of Contents

Method Convert

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Core.dll

Convert<TColumn, TMember>(string, Func<TColumn, TMember>)

Returns a new map in which member receives what convert makes of its column, for a column that needs a trim, a parse or a format on its way to the member. Every other member maps as it did, and this map is unchanged.

public RowMap<T> Convert<TColumn, TMember>(string member, Func<TColumn, TMember> convert)

Parameters

member string

The name of the property (exactly), or of the constructor parameter (ignoring case), that receives the converted value.

convert Func<TColumn, TMember>

Makes the value of the member of the value of the column. It runs once per row.

Returns

RowMap<T>

The new map.

Type Parameters

TColumn

The type the column is read as and the delegate receives: the column's own type, else any type a single value can be read as (Map<TColumn>()); an integer converts only within its range.

TMember

The type the delegate returns: the member's type, or one assignable to it.

Remarks

The column is the one the map already names for the member (a pair), else the one the member matches by name (exactly, ignoring case, then ignoring case and underscores). To name the column here, use Convert<TColumn, TMember>(string, string, Func<TColumn, TMember>). The delegate is not called for a NULL cell, unless TColumn is a Nullable<T> (see RowMap<T>). A lambda does not say what the column is read as: name the types, Convert<long, string>(...), or type the parameter of the lambda.

Exceptions

ArgumentNullException

member or convert is null.

ArgumentException

The member is unknown or unsettable, has a converter already, is mapped to null (it reads no column), or TMember cannot be assigned to it.

Convert<TColumn, TMember>(string, string, Func<TColumn, TMember>)

Returns a new map in which member receives what convert makes of column: a pair (new(member, column)) with a converter. Every other member maps as it did, and this map is unchanged.

public RowMap<T> Convert<TColumn, TMember>(string member, string column, Func<TColumn, TMember> convert)

Parameters

member string

The name of the property (exactly), or of the constructor parameter (ignoring case), that receives the converted value.

column string

The name of the column the member reads.

convert Func<TColumn, TMember>

Makes the value of the member of the value of the column. It runs once per row.

Returns

RowMap<T>

The new map.

Type Parameters

TColumn

The type the column is read as and the delegate receives: the column's own type, else any type a single value can be read as (Map<TColumn>()); an integer converts only within its range.

TMember

The type the delegate returns: the member's type, or one assignable to it.

Remarks

Like a pair, it is matched exactly, else ignoring case. A member the map has a pair for is converted without naming its column: Convert<TColumn, TMember>(string, Func<TColumn, TMember>).

Exceptions

ArgumentNullException

member, column or convert is null.

ArgumentException

The member is unknown or unsettable, is mapped by a pair or has a converter already, column is empty or is read by another member, or TMember cannot be assigned to the member.