Exemplo n.º 1
0
        public void Import(DataFile file)
        {
            if (!context.DatabaseExists(file.database))
            {
                context.CreateDatabase(file.database);
            }

            DataSet dataSet = new DataSet(file.database);

            dataSet.ReadXml(file.path);
            DataTableCollection tables = dataSet.Tables;

            for (int i = 0; i < tables.Count; i++)
            {
                DataTable table       = tables[i];
                string[]  columnNames = new string[table.Columns.Count];

                for (int j = 0; j < table.Columns.Count; j++)
                {
                    columnNames[j] = table.Columns[j].ColumnName;
                }

                string query = SQLQueryGenerator.GetCreateTableQuery(table.TableName, columnNames);
                context.ExecuteNonQuery(query);
            }
        }
Exemplo n.º 2
0
        public void Import(DataFile file)
        {
            string database = file.database;

            if (!context.DatabaseExists(database))
            {
                context.CreateDatabase(database);
                context.ChangeDatabase(database);
            }

            DataTable csvData = CSVReadWrite.ReadCsvDataTable(file.path);

            context.ExecuteBulkCopy((bulkCopy) => CreateDatabaseTable(file, csvData, bulkCopy));
        }