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();
}
}
}