Ejemplo n.º 1
0
 protected bool CanDeepLoad(IEntity entity, string key, string property, DeepLoadType deepLoadType, ChildEntityTypesList innerList)
 {
     if (innerList != null)
     {
         if (deepLoadType == DeepLoadType.ExcludeChildren)
         {
             if (!(innerList.Contains(key) || innerList.HasProperty(entity, key, property)))
             {
                 innerList.AddProperty(entity, key, property);
                 return(true);
             }
         }
         else if ((deepLoadType == DeepLoadType.IncludeChildren) && !(!innerList.Contains(key) || innerList.HasProperty(entity, key, property)))
         {
             innerList.AddProperty(entity, key, property);
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
 internal abstract void DeepLoad(TransactionManager mgr, Entity entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList);
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="LibraryManagement.Domain.Date"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">LibraryManagement.Domain.Date Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, LibraryManagement.Domain.Date entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();

            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Ejemplo n.º 4
0
 internal override void DeepLoad(TransactionManager transactionManager, PaymentItem entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if (entity != null)
     {
         object[] pkItems;
         if (base.CanDeepLoad(entity, "ContractCost", "ContractCostCodeSource", deepLoadType, innerList) && (entity.ContractCostCodeSource == null))
         {
             pkItems = new object[] { entity.ContractCostCode ?? string.Empty };
             ContractCost cost = EntityManager.LocateEntity <ContractCost>(EntityLocator.ConstructKeyFromPkItems(typeof(ContractCost), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (cost != null)
             {
                 entity.ContractCostCodeSource = cost;
             }
             else
             {
                 entity.ContractCostCodeSource = DataRepository.ContractCostProvider.GetByContractCostCode(entity.ContractCostCode ?? string.Empty);
             }
             if (deep && (entity.ContractCostCodeSource != null))
             {
                 DataRepository.ContractCostProvider.DeepLoad(transactionManager, entity.ContractCostCodeSource, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "Payment", "PaymentCodeSource", deepLoadType, innerList) && (entity.PaymentCodeSource == null))
         {
             pkItems = new object[] { entity.PaymentCode ?? string.Empty };
             Payment payment = EntityManager.LocateEntity <Payment>(EntityLocator.ConstructKeyFromPkItems(typeof(Payment), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (payment != null)
             {
                 entity.PaymentCodeSource = payment;
             }
             else
             {
                 entity.PaymentCodeSource = DataRepository.PaymentProvider.GetByPaymentCode(entity.PaymentCode ?? string.Empty);
             }
             if (deep && (entity.PaymentCodeSource != null))
             {
                 DataRepository.PaymentProvider.DeepLoad(transactionManager, entity.PaymentCodeSource, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<PayoutItem>", "PayoutItemCollection", deepLoadType, innerList))
         {
             entity.PayoutItemCollection = DataRepository.PayoutItemProvider.GetByPaymentItemCode(transactionManager, entity.PaymentItemCode);
             if (deep && (entity.PayoutItemCollection.Count > 0))
             {
                 DataRepository.PayoutItemProvider.DeepLoad(transactionManager, entity.PayoutItemCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.ContactType"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.ContactType Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.ContactType entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();

            // Deep load child collections  - Call GetByContactTypeId methods when available

            #region StoreContactCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<StoreContact>|StoreContactCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'StoreContactCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.StoreContactCollection = DataRepository.StoreContactProvider.GetByContactTypeId(transactionManager, entity.ContactTypeId);

                if (deep && entity.StoreContactCollection.Count > 0)
                {
                    deepHandles.Add("StoreContactCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <StoreContact>)DataRepository.StoreContactProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.StoreContactCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            #region VendorContactCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<VendorContact>|VendorContactCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'VendorContactCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.VendorContactCollection = DataRepository.VendorContactProvider.GetByContactTypeId(transactionManager, entity.ContactTypeId);

                if (deep && entity.VendorContactCollection.Count > 0)
                {
                    deepHandles.Add("VendorContactCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <VendorContact>)DataRepository.VendorContactProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.VendorContactCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.TestProduct"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.TestProduct Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.TestProduct entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            DeepHandles deepHandles = new DeepHandles();

            //Fire all DeepLoad Items
            deepHandles.InvokeAll();
            deepHandles = null;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Deep Load the entire Entity object with criteria based on the child types array and the DeepLoadType.
 /// </summary>
 /// <remarks>
 /// Use this method with caution as it is possible to DeepLoad with recursion and traverse an entire collection's object graph.
 /// </remarks>
 /// <param name="entity">The Entity object to load.</param>
 /// <param name="deep">A flag that indicates whether to recursively load all Property Collections that are descendants of this instance. If True, loads the complete object graph below this object. If False, loads this object only.</param>
 /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
 /// <param name="childTypes">Entity Property Collection Type Array To Include or Exclude from Load.</param>
 /// <param name="innerList">A collection of child types for easy access.</param>
 protected virtual void DeepLoad(Entity entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 8
0
 internal override void DeepLoad(TransactionManager transactionManager, Project entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if (entity != null)
     {
         if (base.CanDeepLoad(entity, "List<MaterialPurchas>", "MaterialPurchasCollection", deepLoadType, innerList))
         {
             entity.MaterialPurchasCollection = DataRepository.MaterialPurchasProvider.GetByProjectCode(transactionManager, entity.ProjectCode);
             if (deep && (entity.MaterialPurchasCollection.Count > 0))
             {
                 DataRepository.MaterialPurchasProvider.DeepLoad(transactionManager, entity.MaterialPurchasCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<Payout>", "PayoutCollection", deepLoadType, innerList))
         {
             entity.PayoutCollection = DataRepository.PayoutProvider.GetByProjectCode(transactionManager, entity.ProjectCode);
             if (deep && (entity.PayoutCollection.Count > 0))
             {
                 DataRepository.PayoutProvider.DeepLoad(transactionManager, entity.PayoutCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<Contract>", "ContractCollection", deepLoadType, innerList))
         {
             entity.ContractCollection = DataRepository.ContractProvider.GetByProjectCode(transactionManager, entity.ProjectCode);
             if (deep && (entity.ContractCollection.Count > 0))
             {
                 DataRepository.ContractProvider.DeepLoad(transactionManager, entity.ContractCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<InspectSituation>", "InspectSituationCollection", deepLoadType, innerList))
         {
             entity.InspectSituationCollection = DataRepository.InspectSituationProvider.GetByProjectCode(transactionManager, entity.ProjectCode);
             if (deep && (entity.InspectSituationCollection.Count > 0))
             {
                 DataRepository.InspectSituationProvider.DeepLoad(transactionManager, entity.InspectSituationCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<Payment>", "PaymentCollection", deepLoadType, innerList))
         {
             entity.PaymentCollection = DataRepository.PaymentProvider.GetByProjectCode(transactionManager, entity.ProjectCode);
             if (deep && (entity.PaymentCollection.Count > 0))
             {
                 DataRepository.PaymentProvider.DeepLoad(transactionManager, entity.PaymentCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
     }
 }
 internal override void DeepLoad(TransactionManager transactionManager, MaterialPurchasDtl entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if ((entity != null) && (base.CanDeepLoad(entity, "MaterialPurchas", "MaterialPurchasIDSource", deepLoadType, innerList) && (entity.MaterialPurchasIDSource == null)))
     {
         object[] pkItems           = new object[1];
         int?     materialPurchasID = entity.MaterialPurchasID;
         pkItems[0] = materialPurchasID.HasValue ? materialPurchasID.GetValueOrDefault() : 0;
         MaterialPurchas purchas = EntityManager.LocateEntity <MaterialPurchas>(EntityLocator.ConstructKeyFromPkItems(typeof(MaterialPurchas), pkItems), DataRepository.Provider.EnableEntityTracking);
         if (purchas != null)
         {
             entity.MaterialPurchasIDSource = purchas;
         }
         else
         {
             materialPurchasID = entity.MaterialPurchasID;
             entity.MaterialPurchasIDSource = DataRepository.MaterialPurchasProvider.GetByMaterialPurchasID(materialPurchasID.HasValue ? materialPurchasID.GetValueOrDefault() : 0);
         }
         if (deep && (entity.MaterialPurchasIDSource != null))
         {
             DataRepository.MaterialPurchasProvider.DeepLoad(transactionManager, entity.MaterialPurchasIDSource, deep, deepLoadType, childTypes, innerList);
         }
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.WorkOrder"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.WorkOrder Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.WorkOrder entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region ProductIdSource
            if (CanDeepLoad(entity, "Product|ProductIdSource", deepLoadType, innerList) &&
                entity.ProductIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.ProductId;
                Product tmpEntity = EntityManager.LocateEntity <Product>(EntityLocator.ConstructKeyFromPkItems(typeof(Product), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.ProductIdSource = tmpEntity;
                }
                else
                {
                    entity.ProductIdSource = DataRepository.ProductProvider.GetByProductId(transactionManager, entity.ProductId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ProductIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ProductIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.ProductProvider.DeepLoad(transactionManager, entity.ProductIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion ProductIdSource

            #region ScrapReasonIdSource
            if (CanDeepLoad(entity, "ScrapReason|ScrapReasonIdSource", deepLoadType, innerList) &&
                entity.ScrapReasonIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.ScrapReasonId ?? (short)0);
                ScrapReason tmpEntity = EntityManager.LocateEntity <ScrapReason>(EntityLocator.ConstructKeyFromPkItems(typeof(ScrapReason), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.ScrapReasonIdSource = tmpEntity;
                }
                else
                {
                    entity.ScrapReasonIdSource = DataRepository.ScrapReasonProvider.GetByScrapReasonId(transactionManager, (entity.ScrapReasonId ?? (short)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ScrapReasonIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ScrapReasonIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.ScrapReasonProvider.DeepLoad(transactionManager, entity.ScrapReasonIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion ScrapReasonIdSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();
            // Deep load child collections  - Call GetByWorkOrderId methods when available

            #region WorkOrderRoutingCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<WorkOrderRouting>|WorkOrderRoutingCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'WorkOrderRoutingCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.WorkOrderRoutingCollection = DataRepository.WorkOrderRoutingProvider.GetByWorkOrderId(transactionManager, entity.WorkOrderId);

                if (deep && entity.WorkOrderRoutingCollection.Count > 0)
                {
                    deepHandles.Add("WorkOrderRoutingCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <WorkOrderRouting>)DataRepository.WorkOrderRoutingProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.WorkOrderRoutingCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Ejemplo n.º 11
0
 internal override void DeepLoad(TransactionManager transactionManager, DictionaryItem entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if ((entity != null) && (base.CanDeepLoad(entity, "DictionaryName", "DictionaryNameCodeSource", deepLoadType, innerList) && (entity.DictionaryNameCodeSource == null)))
     {
         object[]       pkItems = new object[] { entity.DictionaryNameCode ?? string.Empty };
         DictionaryName name    = EntityManager.LocateEntity <DictionaryName>(EntityLocator.ConstructKeyFromPkItems(typeof(DictionaryName), pkItems), DataRepository.Provider.EnableEntityTracking);
         if (name != null)
         {
             entity.DictionaryNameCodeSource = name;
         }
         else
         {
             entity.DictionaryNameCodeSource = DataRepository.DictionaryNameProvider.GetByDictionaryNameCode(entity.DictionaryNameCode ?? string.Empty);
         }
         if (deep && (entity.DictionaryNameCodeSource != null))
         {
             DataRepository.DictionaryNameProvider.DeepLoad(transactionManager, entity.DictionaryNameCodeSource, deep, deepLoadType, childTypes, innerList);
         }
     }
 }
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="PetShop.Business.Item"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">PetShop.Business.Item Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, PetShop.Business.Item entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region ProductIdSource
            if (CanDeepLoad(entity, "Product|ProductIdSource", deepLoadType, innerList) &&
                entity.ProductIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.ProductId;
                Product tmpEntity = EntityManager.LocateEntity <Product>(EntityLocator.ConstructKeyFromPkItems(typeof(Product), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.ProductIdSource = tmpEntity;
                }
                else
                {
                    entity.ProductIdSource = DataRepository.ProductProvider.GetByProductId(transactionManager, entity.ProductId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ProductIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ProductIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.ProductProvider.DeepLoad(transactionManager, entity.ProductIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion ProductIdSource

            #region SupplierSource
            if (CanDeepLoad(entity, "Supplier|SupplierSource", deepLoadType, innerList) &&
                entity.SupplierSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.Supplier ?? (int)0);
                Supplier tmpEntity = EntityManager.LocateEntity <Supplier>(EntityLocator.ConstructKeyFromPkItems(typeof(Supplier), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.SupplierSource = tmpEntity;
                }
                else
                {
                    entity.SupplierSource = DataRepository.SupplierProvider.GetBySuppId(transactionManager, (entity.Supplier ?? (int)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'SupplierSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.SupplierSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.SupplierProvider.DeepLoad(transactionManager, entity.SupplierSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion SupplierSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();

            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.Location"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.Location Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.Location entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();

            // Deep load child collections  - Call GetByLocationId methods when available

            #region WorkOrderRoutingCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<WorkOrderRouting>|WorkOrderRoutingCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'WorkOrderRoutingCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.WorkOrderRoutingCollection = DataRepository.WorkOrderRoutingProvider.GetByLocationId(transactionManager, entity.LocationId);

                if (deep && entity.WorkOrderRoutingCollection.Count > 0)
                {
                    deepHandles.Add("WorkOrderRoutingCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <WorkOrderRouting>)DataRepository.WorkOrderRoutingProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.WorkOrderRoutingCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            #region ProductIdProductCollection_From_ProductInventory
            // RelationshipType.ManyToMany
            if (CanDeepLoad(entity, "List<Product>|ProductIdProductCollection_From_ProductInventory", deepLoadType, innerList))
            {
                entity.ProductIdProductCollection_From_ProductInventory = DataRepository.ProductProvider.GetByLocationIdFromProductInventory(transactionManager, entity.LocationId);

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ProductIdProductCollection_From_ProductInventory' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ProductIdProductCollection_From_ProductInventory != null)
                {
                    deepHandles.Add("ProductIdProductCollection_From_ProductInventory",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <Product>)DataRepository.ProductProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.ProductIdProductCollection_From_ProductInventory, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion



            #region ProductInventoryCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<ProductInventory>|ProductInventoryCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ProductInventoryCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.ProductInventoryCollection = DataRepository.ProductInventoryProvider.GetByLocationId(transactionManager, entity.LocationId);

                if (deep && entity.ProductInventoryCollection.Count > 0)
                {
                    deepHandles.Add("ProductInventoryCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <ProductInventory>)DataRepository.ProductInventoryProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.ProductInventoryCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Ejemplo n.º 14
0
 internal void DeepLoad(TransactionManager mgr, TList <Entity> entities, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if (entities == null)
     {
         throw new ArgumentNullException("entities", "A valid non-null, TList<Entity> object is not present.");
     }
     if (!Enum.IsDefined(typeof(DeepLoadType), deepLoadType))
     {
         throw new ArgumentException("A valid DeepLoadType option is not present.", deepLoadType.ToString());
     }
     if (childTypes == null)
     {
         throw new ArgumentNullException("childTypes", "A valid Type[] array is not present.");
     }
     if (deepLoadType != DeepLoadType.Ignore)
     {
         foreach (Entity local in entities)
         {
             this.DeepLoad(mgr, local, deep, deepLoadType, childTypes, innerList);
             innerList.Keys.Remove(local.EntityTrackingKey);
         }
     }
 }
Ejemplo n.º 15
0
 internal override void DeepLoad(TransactionManager transactionManager, ContractBill entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if ((entity != null) && (base.CanDeepLoad(entity, "Contract", "ContractCodeSource", deepLoadType, innerList) && (entity.ContractCodeSource == null)))
     {
         object[] pkItems  = new object[] { entity.ContractCode ?? string.Empty };
         Contract contract = EntityManager.LocateEntity <Contract>(EntityLocator.ConstructKeyFromPkItems(typeof(Contract), pkItems), DataRepository.Provider.EnableEntityTracking);
         if (contract != null)
         {
             entity.ContractCodeSource = contract;
         }
         else
         {
             entity.ContractCodeSource = DataRepository.ContractProvider.GetByContractCode(entity.ContractCode ?? string.Empty);
         }
         if (deep && (entity.ContractCodeSource != null))
         {
             DataRepository.ContractProvider.DeepLoad(transactionManager, entity.ContractCodeSource, deep, deepLoadType, childTypes, innerList);
         }
     }
 }
Ejemplo n.º 16
0
 internal override void DeepLoad(TransactionManager transactionManager, InspectSituation entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if (entity != null)
     {
         object[] pkItems;
         if (base.CanDeepLoad(entity, "Project", "ProjectCodeSource", deepLoadType, innerList) && (entity.ProjectCodeSource == null))
         {
             pkItems = new object[] { entity.ProjectCode ?? string.Empty };
             Project project = EntityManager.LocateEntity <Project>(EntityLocator.ConstructKeyFromPkItems(typeof(Project), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (project != null)
             {
                 entity.ProjectCodeSource = project;
             }
             else
             {
                 entity.ProjectCodeSource = DataRepository.ProjectProvider.GetByProjectCode(entity.ProjectCode ?? string.Empty);
             }
             if (deep && (entity.ProjectCodeSource != null))
             {
                 DataRepository.ProjectProvider.DeepLoad(transactionManager, entity.ProjectCodeSource, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "SystemUser", "InspectUserSource", deepLoadType, innerList) && (entity.InspectUserSource == null))
         {
             pkItems = new object[] { entity.InspectUser ?? string.Empty };
             SystemUser user = EntityManager.LocateEntity <SystemUser>(EntityLocator.ConstructKeyFromPkItems(typeof(SystemUser), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (user != null)
             {
                 entity.InspectUserSource = user;
             }
             else
             {
                 entity.InspectUserSource = DataRepository.SystemUserProvider.GetByUserCode(entity.InspectUser ?? string.Empty);
             }
             if (deep && (entity.InspectUserSource != null))
             {
                 DataRepository.SystemUserProvider.DeepLoad(transactionManager, entity.InspectUserSource, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<Trouble>", "TroubleCollection", deepLoadType, innerList))
         {
             entity.TroubleCollection = DataRepository.TroubleProvider.GetByInspectSituationID(transactionManager, entity.InspectSituationID);
             if (deep && (entity.TroubleCollection.Count > 0))
             {
                 DataRepository.TroubleProvider.DeepLoad(transactionManager, entity.TroubleCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.CurrencyRate"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.CurrencyRate Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.CurrencyRate entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region FromCurrencyCodeSource
            if (CanDeepLoad(entity, "Currency|FromCurrencyCodeSource", deepLoadType, innerList) &&
                entity.FromCurrencyCodeSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.FromCurrencyCode;
                Currency tmpEntity = EntityManager.LocateEntity <Currency>(EntityLocator.ConstructKeyFromPkItems(typeof(Currency), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.FromCurrencyCodeSource = tmpEntity;
                }
                else
                {
                    entity.FromCurrencyCodeSource = DataRepository.CurrencyProvider.GetByCurrencyCode(transactionManager, entity.FromCurrencyCode);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'FromCurrencyCodeSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.FromCurrencyCodeSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.CurrencyProvider.DeepLoad(transactionManager, entity.FromCurrencyCodeSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion FromCurrencyCodeSource

            #region ToCurrencyCodeSource
            if (CanDeepLoad(entity, "Currency|ToCurrencyCodeSource", deepLoadType, innerList) &&
                entity.ToCurrencyCodeSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.ToCurrencyCode;
                Currency tmpEntity = EntityManager.LocateEntity <Currency>(EntityLocator.ConstructKeyFromPkItems(typeof(Currency), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.ToCurrencyCodeSource = tmpEntity;
                }
                else
                {
                    entity.ToCurrencyCodeSource = DataRepository.CurrencyProvider.GetByCurrencyCode(transactionManager, entity.ToCurrencyCode);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ToCurrencyCodeSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ToCurrencyCodeSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.CurrencyProvider.DeepLoad(transactionManager, entity.ToCurrencyCodeSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion ToCurrencyCodeSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();
            // Deep load child collections  - Call GetByCurrencyRateId methods when available

            #region SalesOrderHeaderCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<SalesOrderHeader>|SalesOrderHeaderCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'SalesOrderHeaderCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.SalesOrderHeaderCollection = DataRepository.SalesOrderHeaderProvider.GetByCurrencyRateId(transactionManager, entity.CurrencyRateId);

                if (deep && entity.SalesOrderHeaderCollection.Count > 0)
                {
                    deepHandles.Add("SalesOrderHeaderCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <SalesOrderHeader>)DataRepository.SalesOrderHeaderProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.SalesOrderHeaderCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="EmployeeDB.BLL.SkillLevels"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">EmployeeDB.BLL.SkillLevels Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, EmployeeDB.BLL.SkillLevels entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();

            // Deep load child collections  - Call GetByLevelCode methods when available

            #region EmployeeSkillsCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<EmployeeSkills>|EmployeeSkillsCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'EmployeeSkillsCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.EmployeeSkillsCollection = DataRepository.EmployeeSkillsProvider.GetBySkillLevel(transactionManager, entity.LevelCode);

                if (deep && entity.EmployeeSkillsCollection.Count > 0)
                {
                    deepHandles.Add("EmployeeSkillsCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <EmployeeSkills>)DataRepository.EmployeeSkillsProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.EmployeeSkillsCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Ejemplo n.º 19
0
 internal override void DeepLoad(TransactionManager transactionManager, MaterialPurchas entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if (entity != null)
     {
         if (base.CanDeepLoad(entity, "Project", "ProjectCodeSource", deepLoadType, innerList) && (entity.ProjectCodeSource == null))
         {
             object[] pkItems = new object[] { entity.ProjectCode ?? string.Empty };
             Project  project = EntityManager.LocateEntity <Project>(EntityLocator.ConstructKeyFromPkItems(typeof(Project), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (project != null)
             {
                 entity.ProjectCodeSource = project;
             }
             else
             {
                 entity.ProjectCodeSource = DataRepository.ProjectProvider.GetByProjectCode(entity.ProjectCode ?? string.Empty);
             }
             if (deep && (entity.ProjectCodeSource != null))
             {
                 DataRepository.ProjectProvider.DeepLoad(transactionManager, entity.ProjectCodeSource, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<MaterialPurchasDtl>", "MaterialPurchasDtlCollection", deepLoadType, innerList))
         {
             entity.MaterialPurchasDtlCollection = DataRepository.MaterialPurchasDtlProvider.GetByMaterialPurchasID(transactionManager, new int?(entity.MaterialPurchasID));
             if (deep && (entity.MaterialPurchasDtlCollection.Count > 0))
             {
                 DataRepository.MaterialPurchasDtlProvider.DeepLoad(transactionManager, entity.MaterialPurchasDtlCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
     }
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.PurchaseOrderHeader"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.PurchaseOrderHeader Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.PurchaseOrderHeader entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region EmployeeIdSource
            if (CanDeepLoad(entity, "Employee|EmployeeIdSource", deepLoadType, innerList) &&
                entity.EmployeeIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.EmployeeId;
                Employee tmpEntity = EntityManager.LocateEntity <Employee>(EntityLocator.ConstructKeyFromPkItems(typeof(Employee), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.EmployeeIdSource = tmpEntity;
                }
                else
                {
                    entity.EmployeeIdSource = DataRepository.EmployeeProvider.GetByEmployeeId(transactionManager, entity.EmployeeId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'EmployeeIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.EmployeeIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.EmployeeProvider.DeepLoad(transactionManager, entity.EmployeeIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion EmployeeIdSource

            #region ShipMethodIdSource
            if (CanDeepLoad(entity, "ShipMethod|ShipMethodIdSource", deepLoadType, innerList) &&
                entity.ShipMethodIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.ShipMethodId;
                ShipMethod tmpEntity = EntityManager.LocateEntity <ShipMethod>(EntityLocator.ConstructKeyFromPkItems(typeof(ShipMethod), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.ShipMethodIdSource = tmpEntity;
                }
                else
                {
                    entity.ShipMethodIdSource = DataRepository.ShipMethodProvider.GetByShipMethodId(transactionManager, entity.ShipMethodId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ShipMethodIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ShipMethodIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.ShipMethodProvider.DeepLoad(transactionManager, entity.ShipMethodIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion ShipMethodIdSource

            #region VendorIdSource
            if (CanDeepLoad(entity, "Vendor|VendorIdSource", deepLoadType, innerList) &&
                entity.VendorIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.VendorId;
                Vendor tmpEntity = EntityManager.LocateEntity <Vendor>(EntityLocator.ConstructKeyFromPkItems(typeof(Vendor), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.VendorIdSource = tmpEntity;
                }
                else
                {
                    entity.VendorIdSource = DataRepository.VendorProvider.GetByVendorId(transactionManager, entity.VendorId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'VendorIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.VendorIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.VendorProvider.DeepLoad(transactionManager, entity.VendorIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion VendorIdSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();
            // Deep load child collections  - Call GetByPurchaseOrderId methods when available

            #region PurchaseOrderDetailCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<PurchaseOrderDetail>|PurchaseOrderDetailCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'PurchaseOrderDetailCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.PurchaseOrderDetailCollection = DataRepository.PurchaseOrderDetailProvider.GetByPurchaseOrderId(transactionManager, entity.PurchaseOrderId);

                if (deep && entity.PurchaseOrderDetailCollection.Count > 0)
                {
                    deepHandles.Add("PurchaseOrderDetailCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <PurchaseOrderDetail>)DataRepository.PurchaseOrderDetailProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.PurchaseOrderDetailCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Deep Loads the entire <see cref="TList{Entity}" /> object with criteria based of the child
 /// property collections only N Levels Deep based on the DeepLoadType.
 /// </summary>
 /// <remarks>
 /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire collection's object graph.
 /// </remarks>
 /// <param name="entities">TList of Entity objects to load.</param>
 /// <param name="deep">A flag that indicates whether to recursively load all Property Collections that are descendants of this instance. If True, loads the complete object graph below this object. If False, loads this object only.</param>
 /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
 /// <param name="childTypes">Entity Property Collection Type Array To Include or Exclude from Load.</param>
 public virtual void DeepLoad(TList <Entity> entities, bool deep, DeepLoadType deepLoadType, params System.Type[] childTypes)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.TestIssue117Tablea"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.TestIssue117Tablea Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.TestIssue117Tablea entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();

            // Deep load child collections  - Call GetByTestIssue117TableAid methods when available

            #region TestIssue117TableBidTestIssue117TablebCollection_From_TestIssue117Tablec
            // RelationshipType.ManyToMany
            if (CanDeepLoad(entity, "List<TestIssue117Tableb>|TestIssue117TableBidTestIssue117TablebCollection_From_TestIssue117Tablec", deepLoadType, innerList))
            {
                entity.TestIssue117TableBidTestIssue117TablebCollection_From_TestIssue117Tablec = DataRepository.TestIssue117TablebProvider.GetByTestIssue117TableAidFromTestIssue117Tablec(transactionManager, entity.TestIssue117TableAid);

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'TestIssue117TableBidTestIssue117TablebCollection_From_TestIssue117Tablec' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.TestIssue117TableBidTestIssue117TablebCollection_From_TestIssue117Tablec != null)
                {
                    deepHandles.Add("TestIssue117TableBidTestIssue117TablebCollection_From_TestIssue117Tablec",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <TestIssue117Tableb>)DataRepository.TestIssue117TablebProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.TestIssue117TableBidTestIssue117TablebCollection_From_TestIssue117Tablec, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion



            #region TestIssue117TablecCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<TestIssue117Tablec>|TestIssue117TablecCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'TestIssue117TablecCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.TestIssue117TablecCollection = DataRepository.TestIssue117TablecProvider.GetByTestIssue117TableAid(transactionManager, entity.TestIssue117TableAid);

                if (deep && entity.TestIssue117TablecCollection.Count > 0)
                {
                    deepHandles.Add("TestIssue117TablecCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <TestIssue117Tablec>)DataRepository.TestIssue117TablecProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.TestIssue117TablecCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Ejemplo n.º 23
0
 internal override void DeepLoad(TransactionManager transactionManager, PayoutItem entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if (entity != null)
     {
         object[] pkItems;
         if (base.CanDeepLoad(entity, "Payout", "PayoutCodeSource", deepLoadType, innerList) && (entity.PayoutCodeSource == null))
         {
             pkItems = new object[] { entity.PayoutCode ?? string.Empty };
             Payout payout = EntityManager.LocateEntity <Payout>(EntityLocator.ConstructKeyFromPkItems(typeof(Payout), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (payout != null)
             {
                 entity.PayoutCodeSource = payout;
             }
             else
             {
                 entity.PayoutCodeSource = DataRepository.PayoutProvider.GetByPayoutCode(entity.PayoutCode ?? string.Empty);
             }
             if (deep && (entity.PayoutCodeSource != null))
             {
                 DataRepository.PayoutProvider.DeepLoad(transactionManager, entity.PayoutCodeSource, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "PaymentItem", "PaymentItemCodeSource", deepLoadType, innerList) && (entity.PaymentItemCodeSource == null))
         {
             pkItems = new object[] { entity.PaymentItemCode ?? string.Empty };
             PaymentItem item = EntityManager.LocateEntity <PaymentItem>(EntityLocator.ConstructKeyFromPkItems(typeof(PaymentItem), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (item != null)
             {
                 entity.PaymentItemCodeSource = item;
             }
             else
             {
                 entity.PaymentItemCodeSource = DataRepository.PaymentItemProvider.GetByPaymentItemCode(entity.PaymentItemCode ?? string.Empty);
             }
             if (deep && (entity.PaymentItemCodeSource != null))
             {
                 DataRepository.PaymentItemProvider.DeepLoad(transactionManager, entity.PaymentItemCodeSource, deep, deepLoadType, childTypes, innerList);
             }
         }
     }
 }
Ejemplo n.º 24
0
 internal override void DeepLoad(TransactionManager transactionManager, DictionaryName entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if ((entity != null) && base.CanDeepLoad(entity, "List<DictionaryItem>", "DictionaryItemCollection", deepLoadType, innerList))
     {
         entity.DictionaryItemCollection = DataRepository.DictionaryItemProvider.GetByDictionaryNameCode(transactionManager, entity.DictionaryNameCode);
         if (deep && (entity.DictionaryItemCollection.Count > 0))
         {
             DataRepository.DictionaryItemProvider.DeepLoad(transactionManager, entity.DictionaryItemCollection, deep, deepLoadType, childTypes, innerList);
         }
     }
 }
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.TestIssue117Tablec"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.TestIssue117Tablec Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.TestIssue117Tablec entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region TestIssue117TableAidSource
            if (CanDeepLoad(entity, "TestIssue117Tablea|TestIssue117TableAidSource", deepLoadType, innerList) &&
                entity.TestIssue117TableAidSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.TestIssue117TableAid;
                TestIssue117Tablea tmpEntity = EntityManager.LocateEntity <TestIssue117Tablea>(EntityLocator.ConstructKeyFromPkItems(typeof(TestIssue117Tablea), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.TestIssue117TableAidSource = tmpEntity;
                }
                else
                {
                    entity.TestIssue117TableAidSource = DataRepository.TestIssue117TableaProvider.GetByTestIssue117TableAid(transactionManager, entity.TestIssue117TableAid);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'TestIssue117TableAidSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.TestIssue117TableAidSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.TestIssue117TableaProvider.DeepLoad(transactionManager, entity.TestIssue117TableAidSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion TestIssue117TableAidSource

            #region TestIssue117TableBidSource
            if (CanDeepLoad(entity, "TestIssue117Tableb|TestIssue117TableBidSource", deepLoadType, innerList) &&
                entity.TestIssue117TableBidSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.TestIssue117TableBid;
                TestIssue117Tableb tmpEntity = EntityManager.LocateEntity <TestIssue117Tableb>(EntityLocator.ConstructKeyFromPkItems(typeof(TestIssue117Tableb), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.TestIssue117TableBidSource = tmpEntity;
                }
                else
                {
                    entity.TestIssue117TableBidSource = DataRepository.TestIssue117TablebProvider.GetByTestIssue117TableBid(transactionManager, entity.TestIssue117TableBid);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'TestIssue117TableBidSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.TestIssue117TableBidSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.TestIssue117TablebProvider.DeepLoad(transactionManager, entity.TestIssue117TableBidSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion TestIssue117TableBidSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();

            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="GenTest.Entities.RigaFattura"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">GenTest.Entities.RigaFattura Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        internal override void DeepLoad(TransactionManager transactionManager, GenTest.Entities.RigaFattura entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region ComposedFatturaIDSource
            if (CanDeepLoad(entity, "Fattura|ComposedFatturaIDSource", deepLoadType, innerList) &&
                entity.ComposedFatturaIDSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.ComposedFatturaID ?? (int)0);
                Fattura tmpEntity = EntityManager.LocateEntity <Fattura>(EntityLocator.ConstructKeyFromPkItems(typeof(Fattura), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.ComposedFatturaIDSource = tmpEntity;
                }
                else
                {
                    entity.ComposedFatturaIDSource = DataRepository.FatturaProvider.GetByID(transactionManager, (entity.ComposedFatturaID ?? (int)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ComposedFatturaIDSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ComposedFatturaIDSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.FatturaProvider.DeepLoad(transactionManager, entity.ComposedFatturaIDSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion ComposedFatturaIDSource

            #region AggregatedFatturaIDSource
            if (CanDeepLoad(entity, "Fattura|AggregatedFatturaIDSource", deepLoadType, innerList) &&
                entity.AggregatedFatturaIDSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.AggregatedFatturaID ?? (int)0);
                Fattura tmpEntity = EntityManager.LocateEntity <Fattura>(EntityLocator.ConstructKeyFromPkItems(typeof(Fattura), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.AggregatedFatturaIDSource = tmpEntity;
                }
                else
                {
                    entity.AggregatedFatturaIDSource = DataRepository.FatturaProvider.GetByID(transactionManager, (entity.AggregatedFatturaID ?? (int)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'AggregatedFatturaIDSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.AggregatedFatturaIDSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.FatturaProvider.DeepLoad(transactionManager, entity.AggregatedFatturaIDSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion AggregatedFatturaIDSource

            #region AssociatedFatturaIDSource
            if (CanDeepLoad(entity, "Fattura|AssociatedFatturaIDSource", deepLoadType, innerList) &&
                entity.AssociatedFatturaIDSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.AssociatedFatturaID ?? (int)0);
                Fattura tmpEntity = EntityManager.LocateEntity <Fattura>(EntityLocator.ConstructKeyFromPkItems(typeof(Fattura), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.AssociatedFatturaIDSource = tmpEntity;
                }
                else
                {
                    entity.AssociatedFatturaIDSource = DataRepository.FatturaProvider.GetByID(transactionManager, (entity.AssociatedFatturaID ?? (int)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'AssociatedFatturaIDSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.AssociatedFatturaIDSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.FatturaProvider.DeepLoad(transactionManager, entity.AssociatedFatturaIDSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion AssociatedFatturaIDSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();
            // Deep load child collections  - Call GetByID methods when available

            #region FatturaCollectionGetByAggregatedRigaFatturaID
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<Fattura>|FatturaCollectionGetByAggregatedRigaFatturaID", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'FatturaCollectionGetByAggregatedRigaFatturaID' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.FatturaCollectionGetByAggregatedRigaFatturaID = DataRepository.FatturaProvider.GetByAggregatedRigaFatturaID(transactionManager, entity.ID);

                if (deep && entity.FatturaCollectionGetByAggregatedRigaFatturaID.Count > 0)
                {
                    deepHandles.Add("FatturaCollectionGetByAggregatedRigaFatturaID",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <Fattura>)DataRepository.FatturaProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.FatturaCollectionGetByAggregatedRigaFatturaID, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            #region Fattura
            // RelationshipType.OneToOne
            if (CanDeepLoad(entity, "Fattura|Fattura", deepLoadType, innerList))
            {
                entity.Fattura = DataRepository.FatturaProvider.GetByAssociatedRigaFatturaID(transactionManager, entity.ID);
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'Fattura' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.Fattura != null)
                {
                    deepHandles.Add("Fattura",
                                    new KeyValuePair <Delegate, object>((DeepLoadSingleHandle <Fattura>)DataRepository.FatturaProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.Fattura, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion



            #region FatturaCollectionGetByComposedRigaFatturaID
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<Fattura>|FatturaCollectionGetByComposedRigaFatturaID", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'FatturaCollectionGetByComposedRigaFatturaID' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.FatturaCollectionGetByComposedRigaFatturaID = DataRepository.FatturaProvider.GetByComposedRigaFatturaID(transactionManager, entity.ID);

                if (deep && entity.FatturaCollectionGetByComposedRigaFatturaID.Count > 0)
                {
                    deepHandles.Add("FatturaCollectionGetByComposedRigaFatturaID",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <Fattura>)DataRepository.FatturaProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.FatturaCollectionGetByComposedRigaFatturaID, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="GenTest.Entities.Macchina"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">GenTest.Entities.Macchina Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, GenTest.Entities.Macchina entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region CropAggregationMacchinaIDSource
            if (CanDeepLoad(entity, "Macchina|CropAggregationMacchinaIDSource", deepLoadType, innerList) &&
                entity.CropAggregationMacchinaIDSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.CropAggregationMacchinaID ?? (int)0);
                Macchina tmpEntity = EntityManager.LocateEntity <Macchina>(EntityLocator.ConstructKeyFromPkItems(typeof(Macchina), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.CropAggregationMacchinaIDSource = tmpEntity;
                }
                else
                {
                    entity.CropAggregationMacchinaIDSource = DataRepository.MacchinaProvider.GetByID(transactionManager, (entity.CropAggregationMacchinaID ?? (int)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'CropAggregationMacchinaIDSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.CropAggregationMacchinaIDSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.MacchinaProvider.DeepLoad(transactionManager, entity.CropAggregationMacchinaIDSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion CropAggregationMacchinaIDSource

            #region AssociationMotoreIDSource
            if (CanDeepLoad(entity, "Motore|AssociationMotoreIDSource", deepLoadType, innerList) &&
                entity.AssociationMotoreIDSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.AssociationMotoreID ?? (int)0);
                Motore tmpEntity = EntityManager.LocateEntity <Motore>(EntityLocator.ConstructKeyFromPkItems(typeof(Motore), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.AssociationMotoreIDSource = tmpEntity;
                }
                else
                {
                    entity.AssociationMotoreIDSource = DataRepository.MotoreProvider.GetByID(transactionManager, (entity.AssociationMotoreID ?? (int)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'AssociationMotoreIDSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.AssociationMotoreIDSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.MotoreProvider.DeepLoad(transactionManager, entity.AssociationMotoreIDSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion AssociationMotoreIDSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();
            // Deep load child collections  - Call GetByID methods when available

            #region SpecchiettoCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<Specchietto>|SpecchiettoCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'SpecchiettoCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.SpecchiettoCollection = DataRepository.SpecchiettoProvider.GetByAggregationMacchinaID(transactionManager, entity.ID);

                if (deep && entity.SpecchiettoCollection.Count > 0)
                {
                    deepHandles.Add("SpecchiettoCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <Specchietto>)DataRepository.SpecchiettoProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.SpecchiettoCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            #region MacchinaCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<Macchina>|MacchinaCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'MacchinaCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.MacchinaCollection = DataRepository.MacchinaProvider.GetByCropAggregationMacchinaID(transactionManager, entity.ID);

                if (deep && entity.MacchinaCollection.Count > 0)
                {
                    deepHandles.Add("MacchinaCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <Macchina>)DataRepository.MacchinaProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.MacchinaCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.ProductVendor"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.ProductVendor Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.ProductVendor entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region ProductIdSource
            if (CanDeepLoad(entity, "Product|ProductIdSource", deepLoadType, innerList) &&
                entity.ProductIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.ProductId;
                Product tmpEntity = EntityManager.LocateEntity <Product>(EntityLocator.ConstructKeyFromPkItems(typeof(Product), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.ProductIdSource = tmpEntity;
                }
                else
                {
                    entity.ProductIdSource = DataRepository.ProductProvider.GetByProductId(transactionManager, entity.ProductId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ProductIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ProductIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.ProductProvider.DeepLoad(transactionManager, entity.ProductIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion ProductIdSource

            #region UnitMeasureCodeSource
            if (CanDeepLoad(entity, "UnitMeasure|UnitMeasureCodeSource", deepLoadType, innerList) &&
                entity.UnitMeasureCodeSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.UnitMeasureCode;
                UnitMeasure tmpEntity = EntityManager.LocateEntity <UnitMeasure>(EntityLocator.ConstructKeyFromPkItems(typeof(UnitMeasure), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.UnitMeasureCodeSource = tmpEntity;
                }
                else
                {
                    entity.UnitMeasureCodeSource = DataRepository.UnitMeasureProvider.GetByUnitMeasureCode(transactionManager, entity.UnitMeasureCode);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'UnitMeasureCodeSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.UnitMeasureCodeSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.UnitMeasureProvider.DeepLoad(transactionManager, entity.UnitMeasureCodeSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion UnitMeasureCodeSource

            #region VendorIdSource
            if (CanDeepLoad(entity, "Vendor|VendorIdSource", deepLoadType, innerList) &&
                entity.VendorIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.VendorId;
                Vendor tmpEntity = EntityManager.LocateEntity <Vendor>(EntityLocator.ConstructKeyFromPkItems(typeof(Vendor), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.VendorIdSource = tmpEntity;
                }
                else
                {
                    entity.VendorIdSource = DataRepository.VendorProvider.GetByVendorId(transactionManager, entity.VendorId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'VendorIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.VendorIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.VendorProvider.DeepLoad(transactionManager, entity.VendorIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion VendorIdSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();

            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Ejemplo n.º 29
0
 internal override void DeepLoad(TransactionManager transactionManager, Material entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if ((entity != null) && base.CanDeepLoad(entity, "List<ContractMaterial>", "ContractMaterialCollection", deepLoadType, innerList))
     {
         entity.ContractMaterialCollection = DataRepository.ContractMaterialProvider.GetByMaterialCode(transactionManager, new int?(entity.MaterialCode));
         if (deep && (entity.ContractMaterialCollection.Count > 0))
         {
             DataRepository.ContractMaterialProvider.DeepLoad(transactionManager, entity.ContractMaterialCollection, deep, deepLoadType, childTypes, innerList);
         }
     }
 }
Ejemplo n.º 30
0
 public virtual void DeepLoad(TransactionManager mgr, Entity entity, bool deep, DeepLoadType deepLoadType, params Type[] childTypes)
 {
     if (entity == null)
     {
         throw new ArgumentNullException("entity", "The argument entity, can not be null.");
     }
     if (!Enum.IsDefined(typeof(DeepLoadType), deepLoadType))
     {
         throw new ArgumentException("A valid DeepLoadType option is not present.", "DeepLoadType");
     }
     if (childTypes == null)
     {
         throw new ArgumentNullException("childTypes", "A valid Type[] array is not present.");
     }
     if ((deepLoadType != DeepLoadType.Ignore) && (entity.EntityState != EntityState.Added))
     {
         ChildEntityTypesList innerList = new ChildEntityTypesList();
         for (int i = 0; i < childTypes.Length; i++)
         {
             if (childTypes[i] != null)
             {
                 if (!childTypes[i].IsGenericType)
                 {
                     innerList.Add(childTypes[i].Name);
                 }
                 else
                 {
                     innerList.Add(string.Format("List<{0}>", childTypes[i].GetGenericArguments()[0].Name));
                 }
             }
         }
         this.DeepLoad(mgr, entity, deep, deepLoadType, childTypes, innerList);
     }
 }