Table of Contents

Method Map

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

Map<T>(IExecuteReader, params IEnumerable<KeyValuePair<string, string?>>?)

Locks in a mapping to model type T and returns a deferred MappedQuery<T>. Nothing runs until a terminal (ToList/FirstOrDefault/…) is invoked. The mapping is compiled once per result-set shape and cached, so repeated queries pay no reflection or compilation cost; values are read with typed getters, so nothing is boxed.

public static MappedQuery<T> Map<T>(this IExecuteReader command, params IEnumerable<KeyValuePair<string, string?>>? fieldMappingOverrides) where T : new()

Parameters

command IExecuteReader

The command to read from.

fieldMappingOverrides IEnumerable<KeyValuePair<string, string>>

An override map of field (property) names to column names; a null column value ignores that field.

Returns

MappedQuery<T>

A deferred query whose results are mapped to T.

Type Parameters

T

The model type to map the values to.

Map<T>(IExecuteReader)

Locks in a mapping to model type T and returns a deferred MappedQuery<T>. Nothing runs until a terminal (ToList/FirstOrDefault/…) is invoked. The mapping is compiled once per result-set shape and cached, so repeated queries pay no reflection or compilation cost; values are read with typed getters, so nothing is boxed.

public static MappedQuery<T> Map<T>(this IExecuteReader command) where T : new()

Parameters

command IExecuteReader

The command to read from.

Returns

MappedQuery<T>

A deferred query whose results are mapped to T.

Type Parameters

T

The model type to map the values to.

Map<T>(IExecuteReader, params IEnumerable<(string Field, string? Column)>?)

Locks in a mapping to model type T and returns a deferred MappedQuery<T>. Nothing runs until a terminal (ToList/FirstOrDefault/…) is invoked. The mapping is compiled once per result-set shape and cached, so repeated queries pay no reflection or compilation cost; values are read with typed getters, so nothing is boxed.

public static MappedQuery<T> Map<T>(this IExecuteReader command, params IEnumerable<(string Field, string? Column)>? fieldMappingOverrides) where T : new()

Parameters

command IExecuteReader

The command to read from.

fieldMappingOverrides IEnumerable<(string Field, string Column)>

An override map of field (property) names to column names; a null column value ignores that field.

Returns

MappedQuery<T>

A deferred query whose results are mapped to T.

Type Parameters

T

The model type to map the values to.

Map<T>(IExecuteReader, Func<IDataRecord, T>)

Locks in a custom projection and returns a deferred MappedQuery<T>. Nothing runs until a terminal is invoked; selector is applied per row as the reader streams.

public static MappedQuery<T> Map<T>(this IExecuteReader command, Func<IDataRecord, T> selector)

Parameters

command IExecuteReader

The command to read from.

selector Func<IDataRecord, T>

The transform applied to each IDataRecord.

Returns

MappedQuery<T>

A deferred query whose results are produced by selector.

Type Parameters

T

The type each record is projected to.