private void DataTableBulkInsertCore(OleDbConnection cn)
        {
            DataTable expectedData = CreateDataTableDataSource();

            MsAccessBulkInsert bulkInsert = new MsAccessBulkInsert(cn);

            bulkInsert.DestinationTableName = TableName;
            bulkInsert.Insert(expectedData);

            DataTable actualData = LoadData(cn, TableName);

            MsAccessBulkHelper.CompareTables(actualData, expectedData);
        }
        private void DataTableBulkUpdateCore(OleDbConnection cn)
        {
            DataTable expectedData = CreateExpectedData();

            using (var bulkUpdate = new MsAccessBulkUpdate(cn))
            {
                bulkUpdate.DestinationTableName = TableName;
                bulkUpdate.PrimaryKeyColumn     = PrimaryKeyColumn;
                bulkUpdate.Update(expectedData);
            }

            DataTable actualData = LoadData(cn);

            MsAccessBulkHelper.CompareTables(actualData, expectedData);
        }
        private void IBulkActionDataReaderBulkInsertCore(OleDbConnection cn)
        {
            DataTable expectedData = CreateDataTableDataSource();
            DataTable actualData   = null;

            using (IBulkActionDataReader reader = CreateIDataReaderDataSource())
            {
                MsAccessBulkInsert bulkInsert = new MsAccessBulkInsert(cn);
                bulkInsert.DestinationTableName = TableName;
                bulkInsert.Insert(reader);
                actualData = LoadData(cn, TableName);
            }

            MsAccessBulkHelper.CompareTables(actualData, expectedData);
        }
        public async Task BulkInsertDataFromDataTableIntoMdbAsynchronously()
        {
            Helpers.SkipTestIfJetProviderNotAvailable();
            using (var helper = CreateHelper(ProviderType.Jet, MdbFileName))
            {
                DataTable expectedData = CreateDataTableDataSource();

                MsAccessBulkInsert bulkInsert = new MsAccessBulkInsert(helper.Connection);
                bulkInsert.DestinationTableName = TableName;
                await bulkInsert.InsertAsync(expectedData);

                DataTable actualData = LoadData(helper.Connection, TableName);

                MsAccessBulkHelper.CompareTables(actualData, expectedData);
            }
        }
        private void IBulkActionDataReaderBulkUpdateCore(
            OleDbConnection cn,
            DataTable expectedData,
            Action <IDbConnection, IDbTransaction, string> action)
        {
            using (IBulkActionDataReader reader = CreateDataReaderForUpdate())
                using (var bulkUpdate = new MsAccessBulkUpdate(cn))
                {
                    bulkUpdate.DestinationTableName = TableName;
                    bulkUpdate.PrimaryKeyColumn     = PrimaryKeyColumn;
                    bulkUpdate.TempTableAction      = action;
                    bulkUpdate.Update(reader);
                }

            DataTable actualData = LoadData(cn);

            MsAccessBulkHelper.CompareTables(actualData, expectedData);
        }
        public async Task BulkUpdateDataFromIDataReaderIntoMdbAsynchronously()
        {
            Helpers.SkipTestIfJetProviderNotAvailable();
            using (var helper = CreateHelper(ProviderType.Jet, MdbFileName))
            {
                DataTable expectedData = CreateExpectedData();

                using (IDataReader reader = expectedData.CreateDataReader())
                    using (var bulkUpdate = new MsAccessBulkUpdate(helper.Connection))
                    {
                        bulkUpdate.DestinationTableName = TableName;
                        bulkUpdate.PrimaryKeyColumn     = PrimaryKeyColumn;
                        await bulkUpdate.UpdateAsync(reader);
                    }

                DataTable actualData = LoadData(helper.Connection);
                MsAccessBulkHelper.CompareTables(actualData, expectedData);
            }
        }
        public void BulkUpdateDataFromIDataReaderIntoMdbSynchronouslyWithoutDeadLock()
        {
            AsyncContext.Run(() =>
            {
                Helpers.SkipTestIfJetProviderNotAvailable();
                using (var helper = CreateHelper(ProviderType.Jet, MdbFileName))
                {
                    DataTable expectedData = CreateExpectedData();

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

                    DataTable actualData = LoadData(helper.Connection);
                    MsAccessBulkHelper.CompareTables(actualData, expectedData);
                }
            });
        }
        private void BulkInsertDataFromDataTableWithExplicitColumnMappings(
            OleDbConnection cn,
            string tableName,
            Action <MsAccessBulkInsert> mappingAction)
        {
            DataTable sourceData = CreateDataTableDataSource();

            sourceData.Columns["Id"].ColumnName      = "SourceId";
            sourceData.Columns["ColNote"].ColumnName = "SourceColNote";

            MsAccessBulkInsert bulkInsert = new MsAccessBulkInsert(cn);

            bulkInsert.DestinationTableName = tableName;

            mappingAction(bulkInsert);
            bulkInsert.Insert(sourceData);

            DataTable expectedData = CreateDataTableDataSource(false);
            DataTable actualData   = LoadData(cn, tableName);

            MsAccessBulkHelper.CompareTables(actualData, expectedData);
        }
        public void BulkInsertDataFromIDataReaderIntoMdbSynchronouslyWithoutDeadLock()
        {
            Helpers.SkipTestIfJetProviderNotAvailable();

            AsyncContext.Run(() =>
            {
                using (var helper = CreateHelper(ProviderType.Jet, MdbFileName))
                {
                    DataTable expectedData = CreateDataTableDataSource();
                    DataTable actualData   = null;

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

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