コード例 #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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #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);
            });
        }
コード例 #12
0
        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);
            });
        }