private ColumnSchema GetColumnSchema(string text, int ordinal) { var result = new ColumnSchema(); result.Ordinal = ordinal; var values = text.Split(" "); if (values.Length == 4) { result.Name = values[0]; result.DataType = values[1]; if (values[2] == "NOT") { result.IsNullable = false; } else if (values[2] == "NULL") { result.IsNullable = true; } } else if (values.Length == 2) { result.Name = values[0]; result.DataType = values[1]; result.IsNullable = true; } else if (values.Length == 3) { result.Name = values[0]; result.DataType = values[1]; if (values[2] == "NOT") { result.IsNullable = false; } else if (values[2] == "NULL") { result.IsNullable = true; } } return(result); }
/// <summary> /// Updates the local schema reference based on the current tables and columns in memory /// </summary> private void UpdateSchema() { var schema = new DbSchema2(_databaseId, _name); _tables.ForEach(table => { var tableSchema = new TableSchema2(table.TableId, table.Name, _name, _databaseId, table.Columns.Length); int colIndx = 0; table.Columns.ForEach(column => { var columnSchema = new ColumnSchema(column.Name, column.DataType); tableSchema.Columns[colIndx] = columnSchema; colIndx++; }); schema.Tables.Add(tableSchema); }); _schema = schema; }