public void GetSchemaCollections() { ExecuteSQL("CREATE TABLE parent (id int, name_parent VARCHAR(20), PRIMARY KEY(id))"); ExecuteSQL(@"CREATE TABLE child (id int, name_child VARCHAR(20), parent_id INT, PRIMARY KEY(id), INDEX par_id (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE)"); ExecuteSQL("INSERT INTO parent VALUES(1, 'parent_1')"); ExecuteSQL("INSERT INTO child VALUES(1, 'child_1', 1)"); SchemaProvider schema = new SchemaProvider(Connection); string[] restrictions = new string[5]; restrictions[2] = "parent"; restrictions[1] = Connection.Database; MySqlSchemaCollection schemaCollection = schema.GetSchema("columns", restrictions); Assert.True(schemaCollection.Columns.Count == 20); Assert.True(schemaCollection.Rows.Count == 2); Assert.AreEqual("parent", schemaCollection.Rows[0]["TABLE_NAME"]); Assert.AreEqual("id", schemaCollection.Rows[0]["COLUMN_NAME"]); schemaCollection = schema.GetForeignKeys(restrictions); Assert.True(schemaCollection.AsDataTable().Columns.Contains("REFERENCED_TABLE_NAME")); schemaCollection = schema.GetForeignKeyColumns(restrictions); Assert.True(schemaCollection.AsDataTable().Columns.Contains("REFERENCED_COLUMN_NAME")); schemaCollection = schema.GetUDF(restrictions); Assert.True(schemaCollection.AsDataTable().Columns.Contains("RETURN_TYPE")); schemaCollection = schema.GetUsers(restrictions); Assert.True(schemaCollection.AsDataTable().Columns.Contains("USERNAME")); }
public Import ParseImport(Import import) { Token.ThrowIfCancellationRequested(); var xmlParser = new XmlTreeParser(new XmlRootState()); ITextSource textSource; XDocument doc; try { textSource = new StringTextSource(File.ReadAllText(import.Filename)); (doc, _) = xmlParser.Parse(textSource.CreateReader()); } catch (Exception ex) when(IsNotCancellation(ex)) { LoggingService.LogError("Unhandled error parsing xml document", ex); return(import); } import.Document = new MSBuildDocument(import.Filename, false); import.Document.Build(doc, this); try { import.Document.Schema = SchemaProvider.GetSchema(import.Filename, import.Sdk); } catch (Exception ex) { LoggingService.LogError($"Error loading schema for '{import.Filename}'", ex); } return(import); }
private void FormMain_Load(object sender, EventArgs e) { SchemaProvider provider = new SchemaProvider(); dbSchema = provider.GetSchema(connectionString); InitTreeView(dbSchema); }
protected static XElement GetSchema(string name, IEnumerable <KeyValuePair <string, string> > deltaKey) { List <KeyValuePair <string, string> > list = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("security", "non-admin") }; list.AddRange(deltaKey); SchemaProvider schemaProvider = new SchemaProvider(name); return(schemaProvider.GetSchema(list)); }
public Import ParseImport(Import import) { Token.ThrowIfCancellationRequested(); var xmlParser = new XmlParser(new XmlRootState(), true); ITextSource textSource; try { textSource = TextSourceFactory.CreateNewDocument(import.Filename); xmlParser.Parse(textSource.CreateReader()); } catch (Exception ex) { LoggingService.LogError("Unhandled error parsing xml document", ex); return(import); } var doc = xmlParser.Nodes.GetRoot(); import.Document = new MSBuildDocument(import.Filename, false); import.Document.Build(doc, textSource, this); import.Document.Schema = SchemaProvider.GetSchema(import.Filename, import.Sdk); return(import); }
public XElement GetSchema(string name, IEnumerable <KeyValuePair <string, string> > deltaKey) { SchemaProvider = new SchemaProvider(name); return(SchemaProvider.GetSchema(deltaKey)); }