private void GenerateIndexes(List <DBInfo.Core.Statement.CreateIndex> indexList) { if (!Directory.Exists(OutputDir + "\\" + IndexesDir)) { Directory.CreateDirectory(OutputDir + "\\" + IndexesDir); } List <string> tableNames = (from DBInfo.Core.Statement.CreateIndex ci in indexList select ci.Index.TableName).Distinct <string>().ToList <string>(); foreach (string tableName in tableNames) { List <DBInfo.Core.Statement.CreateIndex> createIndex = (from DBInfo.Core.Statement.CreateIndex ci in indexList where ci.Index.TableName == tableName select ci).ToList <DBInfo.Core.Statement.CreateIndex>(); StatementCollection stCol = new StatementCollection(); stCol.Statement = new Statement[createIndex.Count]; int count = 0; foreach (DBInfo.Core.Statement.CreateIndex ci in createIndex) { CreateIndex xmlIdx = new CreateIndex(); xmlIdx.TableName = ci.Index.TableName; xmlIdx.IndexName = ci.Index.IndexName; xmlIdx.Unique = ci.Index.Unique ? YesNo.Yes : YesNo.No; xmlIdx.Clustered = ci.Index.IsClustered ? YesNo.Yes : YesNo.No; xmlIdx.Columns = new IndexColumn[ci.Index.Columns.Count]; foreach (DBInfo.Core.Model.IndexColumn icol in ci.Index.Columns) { IndexColumn xmlIC = new IndexColumn(); xmlIC.Order = icol.Order == DBInfo.Core.Model.IndexColumn.EnumOrder.Ascending ? SortOrder.Ascending : SortOrder.Descending; xmlIC.Name = icol.Column; xmlIdx.Columns[ci.Index.Columns.IndexOf(icol)] = xmlIC; } stCol.Statement[count] = xmlIdx; count++; } generateXMLOutput(stCol, OutputDir + "\\" + IndexesDir + "\\" + tableName + ".indexes.xml", true); } }
private DBInfo.Core.Statement.CreateIndex ParseCreateIndexStatement(CreateIndex xmlIndex) { DBInfo.Core.Model.Index i = new DBInfo.Core.Model.Index(); i.TableName = xmlIndex.TableName; i.IndexName = xmlIndex.IndexName; i.Unique = xmlIndex.Unique == YesNo.Yes; i.IsClustered = xmlIndex.Clustered == YesNo.Yes; if (xmlIndex.Columns != null) { foreach (IndexColumn xmlIndexCol in xmlIndex.Columns) { DBInfo.Core.Model.IndexColumn ic = new DBInfo.Core.Model.IndexColumn(); ic.Column = xmlIndexCol.Name; ic.Order = xmlIndexCol.Order == SortOrder.Ascending ? DBInfo.Core.Model.IndexColumn.EnumOrder.Ascending : DBInfo.Core.Model.IndexColumn.EnumOrder.Descending; i.Columns.Add(ic); } } DBInfo.Core.Statement.CreateIndex cidx = new DBInfo.Core.Statement.CreateIndex(); cidx.Index = i; return(cidx); }