Exemple #1
0
        /// <summary>
        /// Performs the exporting.
        /// This method navigates through all tables in a database,
        /// exports the content of each of them to the specified data format and then
        /// packs the result files with the specified packer.
        /// </summary>
        public void Export(Func <DatasetInfo, bool> filter = null)
        {
            var datasets = _dbReader.GetDatasets();

            if (datasets.Count > 0)
            {
                _dataPacker.StartPacking(_datasetExporter.FileExtension);
                try {
                    foreach (var table in datasets)
                    {
                        if (string.Equals(table.Name, "__EFMigrationsHistory", StringComparison.InvariantCultureIgnoreCase))
                        {
                            continue;
                        }

                        if (!(filter is null || filter(table)))
                        {
                            continue;
                        }

                        using (var stream = GetPackerStream(table.Name))
                            using (var reader = _dbReader.GetDataReaderForTable(table)) {
                                _logger?.LogInformation($"Exporting table {table.Name}...");
                                _datasetExporter.ExportDataset(reader, stream, table);
                            }
                    }
                }
                finally {
                    _dataPacker.FinishPacking();
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Performs the exporting.
        /// This method navigates through all tables in a database,
        /// exports the content of each of them to the specified data format and then
        /// packs the result files with the specified packer.
        /// </summary>
        public void Export()
        {
            var datasets = _dbReader.GetDatasets();

            if (datasets.Count > 0)
            {
                _dataPacker.StartPacking(_datasetExporter.FileExtension);
                try {
                    foreach (var table in datasets)
                    {
                        if (string.Equals(table.Name, "__EFMigrationsHistory", StringComparison.InvariantCultureIgnoreCase))
                        {
                            continue;
                        }

                        using (var stream = GetPackerStream(table.Name))
                            using (var reader = _dbReader.GetDataReaderForTable(table)) {
                                _datasetExporter.ExportDataset(reader, stream, table);
                            }
                    }
                }
                finally {
                    _dataPacker.FinishPacking();
                }
            }
        }