コード例 #1
0
		public int GetIndexForColumnName(string columnName, ResultSetWrapper rs)
		{
			int index;
			if (!TryRead(columnName, out index))
			{
				index = rs.Target.GetOrdinal(columnName);
				Insert(columnName, index);
			}

			return index;
		}
コード例 #2
0
        public int GetIndexForColumnName(string columnName, ResultSetWrapper rs)
        {
            int index;

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

            return(index);
        }
コード例 #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);
        }
コード例 #4
0
		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;
			}
		}
コード例 #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);
            }
        }
コード例 #6
0
ファイル: ColumnNameCache.cs プロジェクト: ImanRezaeipour/GTS
        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);
            }
        }