Ejemplo n.º 1
0
        public List <string> GetSchemaDifferences(string connectionString)
        {
            var connection = new OleDbConnection(connectionString);

            connection.Open();

            ///////////////////////////////////////////////////////////////////////////////

            try
            {
                LoadSchemas();

                var tableValidator = new TableSchemaValidator(connection);

                ///////////////////////////////////////////////////////////////////////////////

                foreach (var table in _tables)
                {
                    table.Differences = tableValidator.GetSchemaDifferences(table.TableName, table.ProperSchemaXml);
                    if (table.Differences.Any())
                    {
                        table.Differences.Add("");
                    }
                }
            }
            finally
            {
                connection.Close();
            }

            ///////////////////////////////////////////////////////////////////////////////

            return(_tables.SelectMany(x => x.Differences)
                   .ToList());
        }
Ejemplo n.º 2
0
        public void DumpSchemaXml(string connectionString, List <string> tableNames)
        {
            var connection = new OleDbConnection(connectionString);

            connection.Open();

            try
            {
                var tableValidator = new TableSchemaValidator(connection);

                var tables = new List <TableInfo>();

                ///////////////////////////////////////////////////////////////////////////////

                foreach (var table in tableNames)
                {
                    var xml = tableValidator.GetTableSchemaXml(table);

                    tables.Add(new TableInfo
                    {
                        TableName       = table,
                        ProperSchemaXml = xml
                    });
                }

                ///////////////////////////////////////////////////////////////////////////////

                SaveSchemas(tables);
            }
            finally
            {
                connection.Close();
            }
        }