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
commandIExecuteReaderThe command to read from.
fieldMappingOverridesIEnumerable<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
TThe 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
commandIExecuteReaderThe command to read from.
Returns
- MappedQuery<T>
A deferred query whose results are mapped to
T.
Type Parameters
TThe 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
commandIExecuteReaderThe command to read from.
fieldMappingOverridesIEnumerable<(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
TThe 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
commandIExecuteReaderThe command to read from.
selectorFunc<IDataRecord, T>The transform applied to each IDataRecord.
Returns
- MappedQuery<T>
A deferred query whose results are produced by
selector.
Type Parameters
TThe type each record is projected to.