SobekCM.Core.Aggregations.Complete_Item_Aggregation.Add_Parent_Aggregation C# (CSharp) Méthode

Add_Parent_Aggregation() public méthode

Method adds another aggregation as a parent to this
public Add_Parent_Aggregation ( Item_Aggregation_Related_Aggregations Parent_Aggregation ) : void
Parent_Aggregation Item_Aggregation_Related_Aggregations New parent aggregation
Résultat void
        public void Add_Parent_Aggregation(Item_Aggregation_Related_Aggregations Parent_Aggregation)
        {
            // If the list is currently null, create it
            if (Parents == null)
            {
                Parents = new List<Item_Aggregation_Related_Aggregations> {Parent_Aggregation};
            }
            else
            {
                // If this does not exist, add it
                if (!Parents.Contains(Parent_Aggregation))
                {
                    Parents.Add(Parent_Aggregation);
                }
            }
        }

Usage Example

 /// <summary> Adds the child information to the item aggregation object from the datatable extracted from the database </summary>
 /// <param name="AggrInfo">Partially built item aggregation object</param>
 /// <param name="ParentInfo">Datatable from database calls with parent item aggregation information ( from  SobekCM_Get_Item_Aggregation only )</param>
 private static void add_parents(Complete_Item_Aggregation AggrInfo, DataTable ParentInfo)
 {
     foreach (DataRow parentRow in ParentInfo.Rows)
     {
         Item_Aggregation_Related_Aggregations parentObject = new Item_Aggregation_Related_Aggregations(parentRow[0].ToString(), parentRow[1].ToString(), parentRow[3].ToString(), Convert.ToBoolean(parentRow[4]), false);
         AggrInfo.Add_Parent_Aggregation(parentObject);
     }
 }