public TColumnDisplay <IColumnStructure> GetColumnDisplay() { var res = new TColumnDisplay <IColumnStructure>(); var pk = Structure.FindConstraint <IPrimaryKey>(); var pkcols = new List <string>(); if (pk != null) { pkcols = new List <string>(pk.Columns.GetNames()); } if (ResultFields == null) { for (int i = 0; i < Structure.Columns.Count; i++) { var col = Structure.Columns[i]; var di = new ColumnDisplayInfo { IsPrimaryKey = pkcols.Contains(col.ColumnName) }; res.AddColumn(col.ColumnName, i, col); } } else { for (int i = 0; i < Math.Min(Structure.Columns.Count, ResultFields.Count); i++) { var col = Structure.Columns[i]; res.AddColumn(ResultFields[i], i, col); } } return(res); }
//internal static string RowToTableName(DataGridViewRow row) //{ // if (row == null) return "(SOURCE)"; // if (String.IsNullOrEmpty(row.Cells[4].Value.SafeToString())) return row.Cells[2].Value.ToString(); // return row.Cells[4].Value.ToString(); //} public void SavePerspective() { //m_per.Conditions.Server = tbxServer.Text; //m_per.Conditions.ServerChecked = chbServer.Checked; //m_per.Conditions.ServerRegex = chbServerRegex.Checked; //m_per.Conditions.Database = tbxDatabase.Text; //m_per.Conditions.DatabaseChecked = chbDatabase.Checked; //m_per.Conditions.DatabaseRegex = chbDatabaseRegex.Checked; //m_per.Conditions.Schema = tbxSchema.Text; //m_per.Conditions.SchemaChecked = chbSchema.Checked; //m_per.Conditions.SchemaRegex = chbSchemaRegex.Checked; //m_per.Conditions.Table = tbxTable.Text; //m_per.Conditions.TableChecked = chbTable.Checked; //m_per.Conditions.TableRegex = chbTableRegex.Checked; //m_per.Conditions.Columns = (from s in tbxColumns.Text.Split('\n') where !s.IsEmpty() select s.Trim()).ToArray(); //m_per.Conditions.ColumnsChecked = chbColumns.Checked; m_per.Conditions = m_filter.CloneUsingXml(); m_per.Select.From.Relations.Clear(); m_per.Select.Columns.Clear(); foreach (var rel in GetRelations()) { m_per.Select.From.Relations.Add(rel.Clone()); } // data columns foreach (DataGridViewRow row in dataGridViewColumns.Rows) { var datacol = GetColumnSource(row.Cells[1].Value); if (datacol == null) { continue; } var di = new ColumnDisplayInfo { Style = ColumnDisplayInfo.UsageStyle.Value }; var rdata = new DmlfResultField { Expr = new DmlfColumnRefExpression { Column = datacol }, Alias = row.Cells[0].Value.SafeToString(), DisplayInfo = di }; m_per.Select.Columns.Add(rdata); } // lookup columns int colindex = 0; foreach (DataGridViewRow row in dataGridViewColumns.Rows) { var datacol = GetColumnSource(row.Cells[1].Value); var lookup = GetColumnSource(row.Cells[2].Value); if (datacol == null) { continue; } if (lookup != null) { var di = new ColumnDisplayInfo { Style = ColumnDisplayInfo.UsageStyle.Lookup, VisibleColumnIndex = colindex }; var rloo = new DmlfResultField { Expr = new DmlfColumnRefExpression { Column = lookup }, DisplayInfo = di }; m_per.Select.Columns.Add(rloo); } colindex++; } m_per.Select.Columns.NormalizeBaseTables(); m_per.Select.CompleteUpdatingInfo(this); }
public DmlfResultField() { DisplayInfo = new ColumnDisplayInfo(); }