Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataTransferRowCollection"/> class.
        /// </summary>
        /// <param name="reader">The reader to convert.</param>
        internal DataTransferRowCollection(IDataReader reader)
        {
            Validator.ThrowIfNull(reader, nameof(reader));
            Validator.ThrowIfTrue(reader.IsClosed, nameof(reader), "Reader was closed.");

            int rowNumber = 1;

            while (reader.Read())
            {
                if (Columns == null)
                {
                    Columns = new DataTransferColumnCollection(reader);
                }
                DataTransferRows.Add(new DataTransferRow(this, rowNumber));
                int fieldCount = reader.FieldCount;
                var values     = new object[fieldCount];
                reader.GetValues(values);
                for (int i = 0; i < fieldCount; i++)
                {
                    Type columnType = reader[i].GetType();
                    Data.Add(values[i] == null ? TypeUtility.GetDefaultValue(columnType) : DBNull.Value.Equals(values[i]) ? null : values[i]);
                }
                rowNumber++;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1" /> contains a specific value.
 /// </summary>
 /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
 /// <returns>true if <paramref name="item" /> is found in the <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, false.</returns>
 public bool Contains(DataTransferRow item)
 {
     return(DataTransferRows.Contains(item));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Determines the index of a specific item in the <see cref="T:System.Collections.Generic.IList`1" />.
 /// </summary>
 /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.IList`1" />.</param>
 /// <returns>The index of <paramref name="item" /> if found in the list; otherwise, -1.</returns>
 public int IndexOf(DataTransferRow item)
 {
     return(DataTransferRows.IndexOf(item));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Returns an enumerator that iterates through the collection.
 /// </summary>
 /// <returns>A <see cref="T:System.Collections.Generic.IEnumerator`1" /> that can be used to iterate through the collection.</returns>
 public IEnumerator <DataTransferRow> GetEnumerator()
 {
     return(DataTransferRows.GetEnumerator());
 }