public int GetIndexForColumnName(string columnName, ResultSetWrapper rs)
		{
			int index;
			if (!TryRead(columnName, out index))
			{
				index = rs.Target.GetOrdinal(columnName);
				Insert(columnName, index);
			}

			return index;
		}
        public int GetIndexForColumnName(string columnName, ResultSetWrapper rs)
        {
            int index;

            if (!TryRead(columnName, out index))
            {
                index = rs.Target.GetOrdinal(columnName);
                Insert(columnName, index);
            }

            return(index);
        }
Exemple #3
0
        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);

            try
            {
                reader.Dispose();
            }
            catch (Exception e)
            {
                // NH2205 - prevent exceptions when closing the reader from hiding any original exception
                log.Warn("exception closing reader", e);
            }

            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);
        }
		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;
			}
		}
Exemple #5
0
        public int GetIndexForColumnName(string columnName, ResultSetWrapper rs)
        {
            int?cached = Read(columnName);

            if (cached.HasValue)
            {
                return(cached.Value);
            }
            else
            {
                int index = rs.Target.GetOrdinal(columnName);
                Insert(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);
            }
        }