Exemple #1
0
        public void BulkInsertDataFromDataTable()
        {
            DataTable expectedData = CreateDataTableDataSource();
            DataTable actualData   = null;

            using (SqlServerBulkInsert bulkInsert = new SqlServerBulkInsert(ServerHelper.Connection))
            {
                bulkInsert.DestinationTableName = TableName;
                bulkInsert.Insert(expectedData);
            }
            actualData = LoadData(ServerHelper.Connection, TableName);

            SqlServerBulkHelper.CompareTables(actualData, expectedData);
        }
        public async Task BulkUpdateDataFromDataTableAsynchronously()
        {
            DataTable expectedData = CreateExpectedData();

            using (var bulkUpdate = new SqlServerBulkUpdate(ServerHelper.Connection))
            {
                bulkUpdate.DestinationTableName = TableName;
                bulkUpdate.PrimaryKeyColumn     = PrimaryKeyColumn;
                await bulkUpdate.UpdateAsync(expectedData);
            }

            DataTable actualData = LoadData(ServerHelper.Connection);

            SqlServerBulkHelper.CompareTables(actualData, expectedData);
        }
        public void BulkUpdateDataFromDataTable()
        {
            DataTable expectedData = CreateExpectedData();
            DataTable actualData   = null;

            using (var bulkUpdate = new SqlServerBulkUpdate(ServerHelper.Connection))
            {
                bulkUpdate.DestinationTableName = TABLE_NAME;
                bulkUpdate.PrimaryKeyColumn     = PRIMARY_KEY_COLUMN;
                bulkUpdate.Update(expectedData);
            }

            actualData = LoadData(ServerHelper.Connection);

            SqlServerBulkHelper.CompareTables(actualData, expectedData);
        }
        public void BulkUpdateDataFromIBulkInsertDataReader()
        {
            DataTable expectedData = CreateExpectedData();

            using (IBulkActionDataReader reader = CreateDataReaderForUpdate())
                using (var bulkUpdate = new SqlServerBulkUpdate(ServerHelper.Connection))
                {
                    bulkUpdate.DestinationTableName = TableName;
                    bulkUpdate.PrimaryKeyColumn     = PrimaryKeyColumn;
                    bulkUpdate.Update(reader);
                }

            DataTable actualData = LoadData(ServerHelper.Connection);

            SqlServerBulkHelper.CompareTables(actualData, expectedData);
        }
Exemple #5
0
        public void BulkInsertDataFromIDataReaderIgnoreCaseInColumnNames()
        {
            DataTable expectedData = CreateDataTableDataSource(false);
            DataTable actualData   = null;

            using (IBulkActionDataReader reader = CreateIDataReaderDataSource(false))
            {
                using (SqlServerBulkInsert bulkInsert = new SqlServerBulkInsert(ServerHelper.Connection))
                {
                    bulkInsert.DestinationTableName = TableName_IgnoreCaseInColumnNames;
                    bulkInsert.Insert(reader);
                }
                actualData = LoadData(ServerHelper.Connection, TableName_IgnoreCaseInColumnNames);
            }

            SqlServerBulkHelper.CompareTables(actualData, expectedData);
        }
Exemple #6
0
        public void BulkInsertDataFromIDataReaderShortText()
        {
            DataTable expectedData = CreateDataTableShortText();
            DataTable actualData   = null;

            using (IBulkActionDataReader reader = CreateIDataReaderShortText())
            {
                using (SqlServerBulkInsert bulkInsert = new SqlServerBulkInsert(ServerHelper.Connection))
                {
                    bulkInsert.DestinationTableName = TableName_PrimitiveDataTypes;
                    bulkInsert.Insert(reader);
                }
                actualData = LoadData(ServerHelper.Connection, TableName_PrimitiveDataTypes);
            }

            SqlServerBulkHelper.CompareTables(actualData, expectedData);
        }
Exemple #7
0
        private void BulkInsertDataFromIBulkActionDataReaderCore()
        {
            DataTable expectedData = CreateDataTableDataSource();
            DataTable actualData   = null;

            using (IBulkActionDataReader reader = CreateIDataReaderDataSource(true))
            {
                using (SqlServerBulkInsert bulkInsert = new SqlServerBulkInsert(ServerHelper.Connection))
                {
                    bulkInsert.DestinationTableName = TableName;
                    bulkInsert.Insert(reader);
                }
                actualData = LoadData(ServerHelper.Connection, TableName);
            }

            SqlServerBulkHelper.CompareTables(actualData, expectedData);
        }
Exemple #8
0
        public async Task BulkInsertDataFromIBulkActionDataReaderAsynchronously()
        {
            DataTable expectedData = CreateDataTableDataSource();
            DataTable actualData   = null;

            using (IBulkActionDataReader reader = CreateIDataReaderDataSource(true))
            {
                using (SqlServerBulkInsert bulkInsert = new SqlServerBulkInsert(ServerHelper.Connection))
                {
                    bulkInsert.DestinationTableName = TableName;
                    await bulkInsert.InsertAsync(reader);
                }
                actualData = LoadData(ServerHelper.Connection, TableName);
            }

            SqlServerBulkHelper.CompareTables(actualData, expectedData);
        }
        public async Task BulkUpdateDataFromIBulkInsertDataReaderAsynchronously()
        {
            DataTable expectedData = CreateExpectedData();
            DataTable actualData   = null;

            using (IBulkActionDataReader reader = CreateDataReaderForUpdate())
                using (var bulkUpdate = new SqlServerBulkUpdate(ServerHelper.Connection))
                {
                    bulkUpdate.DestinationTableName = TABLE_NAME;
                    bulkUpdate.PrimaryKeyColumn     = PRIMARY_KEY_COLUMN;
                    await bulkUpdate.UpdateAsync(reader);
                }

            actualData = LoadData(ServerHelper.Connection);

            SqlServerBulkHelper.CompareTables(actualData, expectedData);
        }
        public void BulkUpdateDataFromIDataReaderWithAction()
        {
            DataTable expectedData = CreateExpectedDataWithAction();
            DataTable actualData   = null;

            using (IBulkActionDataReader reader = CreateDataReaderForUpdate())
                using (var bulkUpdate = new SqlServerBulkUpdate(ServerHelper.Connection))
                {
                    bulkUpdate.DestinationTableName = TABLE_NAME;
                    bulkUpdate.PrimaryKeyColumn     = PRIMARY_KEY_COLUMN;
                    bulkUpdate.TempTableAction      = UpdateTempItems;
                    bulkUpdate.Update(reader);
                }

            actualData = LoadData(ServerHelper.Connection);

            SqlServerBulkHelper.CompareTables(actualData, expectedData);
        }
Exemple #11
0
        public void BulkInsertDataFromIDataReaderSynchronouslyWithoutDeadLock()
        {
            AsyncContext.Run(() =>
            {
                DataTable expectedData = CreateDataTableDataSource();
                DataTable actualData   = null;

                using (IDataReader reader = expectedData.CreateDataReader())
                {
                    using (SqlServerBulkInsert bulkInsert = new SqlServerBulkInsert(ServerHelper.Connection))
                    {
                        bulkInsert.DestinationTableName = TableName;
                        bulkInsert.Insert(reader);
                    }
                    actualData = LoadData(ServerHelper.Connection, TableName);
                }

                SqlServerBulkHelper.CompareTables(actualData, expectedData);
            });
        }
        public void BulkUpdateDataFromIDataReaderSynchronouslyWithoutDeadLock()
        {
            AsyncContext.Run(() =>
            {
                DataTable expectedData = CreateExpectedData();
                DataTable actualData   = null;

                using (IDataReader reader = expectedData.CreateDataReader())
                    using (var bulkUpdate = new SqlServerBulkUpdate(ServerHelper.Connection))
                    {
                        bulkUpdate.DestinationTableName = TableName;
                        bulkUpdate.PrimaryKeyColumn     = PrimaryKeyColumn;
                        bulkUpdate.Update(reader);
                    }

                actualData = LoadData(ServerHelper.Connection);

                SqlServerBulkHelper.CompareTables(actualData, expectedData);
            });
        }