示例#1
0
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="DbDataRecordEnumerator"/> class.
        /// </summary>
        /// <param name="reader">The data reader instance, containing
        /// the result set.</param>
        /// <param name="lookup">The column name lookup dictionary.</param>
        public DbDataRecordEnumerator(IDbDataReader reader,
                                      DbFieldLookup lookup)
        {
            Precondition.Require(reader, () => Error.ArgumentNull("reader"));
            Precondition.Require(lookup, () => Error.ArgumentNull("lookup"));

            _reader     = reader;
            _lookup     = lookup;
            _enumerator = new DbEnumerator(_reader, false);
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance
        /// of the <see cref="DbDataRecord"/> class.
        /// </summary>
        /// <param name="record">An <see cref="IDataRecord"/>
        /// instance, which will be used to fill the value set.</param>
        internal DbDataRecord(IDataRecord record, DbFieldLookup lookup)
        {
            Precondition.Require(record, () => Error.ArgumentNull("record"));
            Precondition.Require(lookup, () => Error.ArgumentNull("lookup"));

            _dataRecord   = record;
            _lookup       = lookup;
            _accessedKeys = new HashSet <string>(
                StringComparer.InvariantCultureIgnoreCase);
        }
        private static DbFieldLookup CreateLookupTable(IDataRecord record)
        {
            DbFieldLookup lookup = new DbFieldLookup();

            for (int i = 0; i < record.FieldCount; ++i)
            {
                lookup.Add(i, record.GetName(i));
            }

            return(lookup);
        }
        private static ICollection <DbQueryResultRow> CreateResultSet(IDataReader reader)
        {
            List <DbQueryResultRow> rows = new List <DbQueryResultRow>();

            if (reader.Read())
            {
                DbFieldLookup lookup = CreateLookupTable(reader);
                do
                {
                    rows.Add(new DbQueryResultRow(lookup, reader));
                }while (reader.Read());
            }
            return(rows);
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="Radischevo.Wahha.Data.DbQueryResultRow"/> class.
        /// </summary>
        /// <param name="lookup">The result field lookup helper.</param>
        /// <param name="record">The data record to extract values from.</param>
        public DbQueryResultRow(DbFieldLookup lookup, IDataRecord record)
            : base()
        {
            Precondition.Require(lookup, () => Error.ArgumentNull("lookup"));
            Precondition.Require(record, () => Error.ArgumentNull("record"));

            int fieldCount = record.FieldCount;

            _lookup       = lookup;
            _values       = new object[fieldCount];
            _dataTypes    = new string[fieldCount];
            _accessedKeys = new HashSet <string>();

            record.GetValues(_values);

            for (int i = 0; i < fieldCount; ++i)
            {
                _dataTypes[i] = record.GetDataTypeName(i);
            }
        }