nHydrate.Generator.Models.Table.GetTableHierarchy C# (CSharp) Method

GetTableHierarchy() public method

Get the full hierarchy of tables starting with this table and working back to the most base table
public GetTableHierarchy ( ) : IEnumerable
return IEnumerable
        public IEnumerable<Table> GetTableHierarchy()
        {
            var retval = new List<Table>();
            var t = this;
            while (t != null)
            {
                retval.Add(t);
                t = t.ParentTable;
            }
            retval.Reverse();
            return retval;
        }

Usage Example

Ejemplo n.º 1
0
        private void ReloadControl()
        {
            if (ControllerListView != null)
            {
                ControllerListView.BeginUpdate();
            }

            try
            {
                var   referenceCollection = (ReferenceCollection)this.Object;
                Table parentTable         = null;
                if (referenceCollection.Parent is Table)
                {
                    parentTable = (Table)referenceCollection.Parent;
                }

                //Load the list
                var shallowColumnNames = new List <string>();
                ControllerListView.Items.Clear();
                foreach (Reference reference in referenceCollection)
                {
                    var column = ((Column)reference.Object);
                    shallowColumnNames.Add(column.Name.ToLower());
                    this.AddColumnNode(reference, column);
                }

                //Load the inherited columns
                if (parentTable != null)
                {
                    var allTables = new List <Table>(parentTable.GetTableHierarchy());
                    allTables.Remove(parentTable);

                    //Loop through all base tables and list columns that are NOT included in this table (the PK/audit columns)
                    foreach (var table in allTables)
                    {
                        foreach (var column in table.GeneratedColumns)
                        {
                            if (!shallowColumnNames.Contains(column.Name.ToLower()))
                            {
                                shallowColumnNames.Add(column.Name.ToLower());                                 //just in case, no duplicates
                                this.AddColumnNode(column);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (ControllerListView != null)
                {
                    ControllerListView.EndUpdate();
                }
            }
        }
All Usage Examples Of nHydrate.Generator.Models.Table::GetTableHierarchy