Пример #1
0
        public void Add(ITableInfo tableInfo, LoadStage loadStage)
        {
            //we already have it or it is not setup properly
            if (items.Any(i => i.Tag.Equals(tableInfo)) || string.IsNullOrWhiteSpace(tableInfo.Database) || string.IsNullOrWhiteSpace(tableInfo.Server))
            {
                return;
            }

            var runtimeName = tableInfo.GetRuntimeName(loadStage);
            var dbName      = tableInfo.GetDatabaseRuntimeName(loadStage);

            var syntaxHelper = tableInfo.GetQuerySyntaxHelper();
            var fullSql      = syntaxHelper.EnsureFullyQualified(dbName, null, runtimeName);

            var snip = new SubstringAutocompleteItem(tableInfo.GetRuntimeName());

            snip.MenuText   = runtimeName; //name of table
            snip.Text       = fullSql;     //full SQL
            snip.Tag        = tableInfo;   //record object for future reference
            snip.ImageIndex = GetIndexFor(tableInfo, RDMPConcept.TableInfo.ToString());


            foreach (IHasStageSpecificRuntimeName o in tableInfo.GetColumnsAtStage(loadStage))
            {
                var preDiscarded = o as PreLoadDiscardedColumn;
                var columnInfo   = o as ColumnInfo;

                if (preDiscarded != null)
                {
                    Add(preDiscarded, tableInfo, dbName);
                }
                else
                if (columnInfo != null)
                {
                    Add(columnInfo, tableInfo, dbName, loadStage, syntaxHelper);
                }
                else
                {
                    throw new Exception("Expected IHasStageSpecificRuntimeName returned by TableInfo.GetColumnsAtStage to return only ColumnInfos and PreLoadDiscardedColumns.  It returned a '" + o.GetType().Name + "'");
                }
            }

            AddUnlessDuplicate(snip);
        }