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
memberstringThe name of the property (exactly), or of the constructor parameter (ignoring case), that receives the converted value.
convertFunc<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
TColumnThe 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.TMemberThe 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
memberorconvertis null.- ArgumentException
The member is unknown or unsettable, has a converter already, is mapped to null (it reads no column), or
TMembercannot 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
memberstringThe name of the property (exactly), or of the constructor parameter (ignoring case), that receives the converted value.
columnstringThe name of the column the member reads.
convertFunc<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
TColumnThe 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.TMemberThe 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,columnorconvertis null.- ArgumentException
The member is unknown or unsettable, is mapped by a pair or has a converter already,
columnis empty or is read by another member, orTMembercannot be assigned to the member.