Class ColumnReaderAttribute
Attribute specify parameter index of reader column ordinal for custom reader method that accepts reader and column ordinal parameters. This information is used by mapper builder for queries with SequentialAccess behavior enabled. Alternative approach (when possible) is to move reading of raw value from reader to external expression and passing it to custom reader.
// such helper requires attribute to work in SequentialAccess mode
[ColumnReader(1)]
static int GetCustomInt(DbDataReader rd, int ordinal) => int.Parse(rd.GetString(ordinal));
ReaderExpressions[...] = (rd, i) => GetCustomInt(rd, i);
// such helper will work without attribute
static int GetCustomInt(string value) => int.Parse(value);
ReaderExpressions[...] = (rd, i) => GetCustomInt(rd.GetString(i));
[AttributeUsage(AttributeTargets.Method)]
public class ColumnReaderAttribute : Attribute, _Attribute
- Inheritance
-
objectColumnReaderAttribute
- Implements
- Inherited Members
- Extension Methods
Constructors
ColumnReaderAttribute(int)
public ColumnReaderAttribute(int indexParameterIndex)
Parameters
indexParameterIndexint
Properties
IndexParameterIndex
public int IndexParameterIndex { get; }