DALs.Sql/Extractions/DataReaderExtractions.cs
/// <summary>
/// Gets the reader value by column name.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="reader">The reader.</param>
/// <param name="columnName">Name of the column.</param>
/// <param name="defaultVal">The default value.</param>
/// <returns>T.</returns>
Gets the reader value by column name.
Gets the reader value by column name .
public static T Get<T>(this IDataReader reader, string columnName, T defaultVal = default(T))
        {
            int index;
            try
            {
                index = reader.GetOrdinal(columnName);
            }
            catch (IndexOutOfRangeException)
            {
                Trace.TraceError("Cannot find the column named: {0}", columnName);
                throw;
            }
            return reader.Get(index, defaultVal);
        }
public static T Get < T > ( this IDataReader reader , string columnName , T defaultVal = default ( T ) ) { int index ; try { index = reader . GetOrdinal ( columnName ) ; } catch ( IndexOutOfRangeException ) { Trace . TraceError ( " " , columnName ) ; throw ; } return reader . Get ( index , defaultVal ) ; }
Gets the reader value by column name.
Gets the reader value by column name .
None
IDataReader
this
columnName
string
Name of the column.
Name of the column .
defaultVal
T
The default value.
The default value .
reader
None
typeparam
None