public int GetIndexForColumnName(string columnName, ResultSetWrapper rs) { int? cached; columnNameToIndexCache.TryGetValue(columnName, out cached); if (cached.HasValue) { return cached.Value; } else { int index = rs.Target.GetOrdinal(columnName); columnNameToIndexCache[columnName] = index; return index; } }
public int GetIndexForColumnName(string columnName, ResultSetWrapper rs) { int?cached; columnNameToIndexCache.TryGetValue(columnName, out cached); if (cached.HasValue) { return(cached.Value); } else { int index = rs.Target.GetOrdinal(columnName); columnNameToIndexCache[columnName] = index; return(index); } }
public void CloseReader(IDataReader reader) { /* This method was added because PrepareCommand don't really prepare the command * with its connection. * In some case we need to manage a reader outsite the command scope. * To do it we need to use the Batcher.ExecuteReader and then we need something * to close the opened reader. */ // TODO NH: Study a way to use directly IDbCommand.ExecuteReader() outsite the batcher // An example of it's use is the management of generated ID. if (reader == null) { return; } ResultSetWrapper rsw = reader as ResultSetWrapper; var actualReader = rsw == null ? reader : rsw.Target; readersToClose.Remove(actualReader); reader.Dispose(); LogCloseReader(); if (!log.IsDebugEnabled) { return; } var nhReader = actualReader as NHybridDataReader; actualReader = nhReader == null ? actualReader : nhReader.Target; Stopwatch duration; if (readersDuration.TryGetValue(actualReader, out duration) == false) { return; } readersDuration.Remove(actualReader); log.DebugFormat("DataReader was closed after {0} ms", duration.ElapsedMilliseconds); }