Exemplo n.º 1
0
        protected override void Initialize()
        {
            this.parentRelationNames = new List <string>();
            this.childRelationNames  = new List <string>();

            DataTable table = this.List as DataTable;

            if (table == null && this.List is DataView)
            {
                table = ((DataView)this.List).Table;
            }

            if (table == null)
            {
                return;
            }

            this.Properties = ListBindingHelper.GetListItemProperties(table);
            this.Name       = table.TableName;

            for (int i = 0; i < table.ChildRelations.Count; i++)
            {
                DataTable childTable = table.ChildRelations[i].ChildTable;

                if (childTable == table)
                {
                    this.ChildRelations.Add(new SelfReferenceRelation(childTable,
                                                                      table.ChildRelations[i].ParentColumns[0].ColumnName,
                                                                      table.ChildRelations[i].ChildColumns[0].ColumnName));
                }
                else
                {
                    DataSetObjectRelation child = new DataSetObjectRelation(childTable);
                    child.Parent = this;

                    for (int j = 0; j < table.ChildRelations[i].ParentColumns.Length; j++)
                    {
                        child.parentRelationNames.Add(table.ChildRelations[i].ParentColumns[j].ColumnName);
                    }

                    for (int j = 0; j < table.ChildRelations[i].ChildColumns.Length; j++)
                    {
                        child.childRelationNames.Add(table.ChildRelations[i].ChildColumns[j].ColumnName);
                    }
                    this.ChildRelations.Add(child);
                }
            }
        }
Exemplo n.º 2
0
        protected override void Initialize()
        {
            this.parentRelationNames = new List <string>();
            this.childRelationNames  = new List <string>();
            DataTable dataTable = this.List as DataTable;

            if (dataTable == null && this.List is DataView)
            {
                dataTable = ((DataView)this.List).Table;
            }
            if (dataTable == null)
            {
                return;
            }
            this.Properties = ListBindingHelper.GetListItemProperties((object)dataTable);
            this.Name       = dataTable.TableName;
            for (int index1 = 0; index1 < dataTable.ChildRelations.Count; ++index1)
            {
                DataTable childTable = dataTable.ChildRelations[index1].ChildTable;
                if (childTable == dataTable)
                {
                    this.ChildRelations.Add((ObjectRelation) new SelfReferenceRelation((object)childTable, dataTable.ChildRelations[index1].ParentColumns[0].ColumnName, dataTable.ChildRelations[index1].ChildColumns[0].ColumnName));
                }
                else
                {
                    DataSetObjectRelation setObjectRelation = new DataSetObjectRelation((object)childTable);
                    setObjectRelation.Parent = (ObjectRelation)this;
                    for (int index2 = 0; index2 < dataTable.ChildRelations[index1].ParentColumns.Length; ++index2)
                    {
                        setObjectRelation.parentRelationNames.Add(dataTable.ChildRelations[index1].ParentColumns[index2].ColumnName);
                    }
                    for (int index2 = 0; index2 < dataTable.ChildRelations[index1].ChildColumns.Length; ++index2)
                    {
                        setObjectRelation.childRelationNames.Add(dataTable.ChildRelations[index1].ChildColumns[index2].ColumnName);
                    }
                    this.ChildRelations.Add((ObjectRelation)setObjectRelation);
                }
            }
        }