Exemple #1
0
 public SqlServerInsertBatchTable(SqlServerDataSourceBase dataSource, SqlServerObjectName tableName, DbDataReader dataReader, SqlServerObjectName tableTypeName, InsertOptions options) : base(dataSource)
 {
     m_Source    = dataReader;
     m_Options   = options;
     m_Table     = dataSource.DatabaseMetadata.GetTableOrView(tableName);
     m_TableType = dataSource.DatabaseMetadata.GetUserDefinedTableType(tableTypeName);
 }
Exemple #2
0
    /// <summary>
    /// Initializes a new instance of the <see cref="ObjectDataReader{TObject}" /> class.
    /// </summary>
    /// <param name="tableType">Type of the table.</param>
    /// <param name="source">The source.</param>
    /// <param name="operationType">Type of the operation being performed.</param>
    public ObjectDataReader(UserDefinedTableTypeMetadata tableType, IEnumerable <TObject> source, OperationTypes operationType = OperationTypes.None)
    {
        if (tableType == null)
        {
            throw new ArgumentNullException(nameof(tableType), $"{nameof(tableType)} is null.");
        }
        if (source == null)
        {
            throw new ArgumentNullException(nameof(source), $"{nameof(source)} is null.");
        }

        //Don't use IEnumerable<T>.Count(), as we don't want to preemptively materialize a lazy collection
        if (source is ICollection collection)
        {
            m_RecordCount = collection.Count;
        }

        m_Source = source.GetEnumerator();
        var metadata = BuildStructure(tableType.Name, tableType.Columns, true, operationType);

        m_Schema         = metadata.Schema;
        m_PropertyList   = metadata.Properties;
        m_PropertyLookup = metadata.PropertyLookup;
    }