Example #1
0
        /// <summary>
        ///     Deletes a row from the DataSource.
        /// </summary>
        /// <param name="_workOrderId">Primary key for WorkOrder records.. Primary Key.</param>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <remarks>Deletes based on primary key(s).</remarks>
        /// <returns>Returns true if operation suceeded.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
        public override bool Delete(TransactionManager transactionManager, System.Int32 _workOrderId)
        {
            SqlDatabase database       = new SqlDatabase(this._connectionString);
            DbCommand   commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "Production.usp_adwTiers_WorkOrder_Delete", _useStoredProcedure);

            database.AddInParameter(commandWrapper, "@WorkOrderId", DbType.Int32, _workOrderId);

            //Provider Data Requesting Command Event
            OnDataRequesting(new CommandEventArgs(commandWrapper, "Delete"));

            int results = 0;

            if (transactionManager != null)
            {
                results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
            }
            else
            {
                results = Utility.ExecuteNonQuery(database, commandWrapper);
            }

            //Stop Tracking Now that it has been updated and persisted.
            if (DataRepository.Provider.EnableEntityTracking)
            {
                string entityKey = EntityLocator.ConstructKeyFromPkItems(typeof(WorkOrder)
                                                                         , _workOrderId);
                EntityManager.StopTracking(entityKey);
            }

            //Provider Data Requested Command Event
            OnDataRequested(new CommandEventArgs(commandWrapper, "Delete"));

            commandWrapper = null;

            return(Convert.ToBoolean(results));
        }        //end Delete
Example #2
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.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;
        }
Example #4
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;
        }
        /// <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;
        }
Example #6
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;
        }
Example #7
0
 internal override void DeepLoad(TransactionManager transactionManager, ContractMaterialPlan entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if ((entity != null) && (base.CanDeepLoad(entity, "ContractMaterial", "ContractMaterialCodeSource", deepLoadType, innerList) && (entity.ContractMaterialCodeSource == null)))
     {
         object[]         pkItems  = new object[] { entity.ContractMaterialCode ?? string.Empty };
         ContractMaterial material = EntityManager.LocateEntity <ContractMaterial>(EntityLocator.ConstructKeyFromPkItems(typeof(ContractMaterial), pkItems), DataRepository.Provider.EnableEntityTracking);
         if (material != null)
         {
             entity.ContractMaterialCodeSource = material;
         }
         else
         {
             entity.ContractMaterialCodeSource = DataRepository.ContractMaterialProvider.GetByContractMaterialCode(entity.ContractMaterialCode ?? string.Empty);
         }
         if (deep && (entity.ContractMaterialCodeSource != null))
         {
             DataRepository.ContractMaterialProvider.DeepLoad(transactionManager, entity.ContractMaterialCodeSource, deep, deepLoadType, childTypes, innerList);
         }
     }
 }
Example #8
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;
        }
 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);
         }
     }
 }
Example #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;
        }
        /// <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;
        }
        /// <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.Address"/> 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.Address 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.Address entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region CountryCodeSource
            if (CanDeepLoad(entity, "Countries|CountryCodeSource", deepLoadType, innerList) &&
                entity.CountryCodeSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.CountryCode ?? string.Empty);
                Countries tmpEntity = EntityManager.LocateEntity <Countries>(EntityLocator.ConstructKeyFromPkItems(typeof(Countries), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.CountryCodeSource = tmpEntity;
                }
                else
                {
                    entity.CountryCodeSource = DataRepository.CountriesProvider.GetByCountryCode(transactionManager, (entity.CountryCode ?? string.Empty));
                }

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

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

            #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

            //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;
        }
Example #13
0
 internal override void DeepLoad(TransactionManager transactionManager, Contract 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<ContractCost>", "ContractCostCollection", deepLoadType, innerList))
         {
             entity.ContractCostCollection = DataRepository.ContractCostProvider.GetByContractCode(transactionManager, entity.ContractCode);
             if (deep && (entity.ContractCostCollection.Count > 0))
             {
                 DataRepository.ContractCostProvider.DeepLoad(transactionManager, entity.ContractCostCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<Payment>", "PaymentCollection", deepLoadType, innerList))
         {
             entity.PaymentCollection = DataRepository.PaymentProvider.GetByContractCode(transactionManager, entity.ContractCode);
             if (deep && (entity.PaymentCollection.Count > 0))
             {
                 DataRepository.PaymentProvider.DeepLoad(transactionManager, entity.PaymentCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<ContractChange>", "ContractChangeCollection", deepLoadType, innerList))
         {
             entity.ContractChangeCollection = DataRepository.ContractChangeProvider.GetByContractCode(transactionManager, entity.ContractCode);
             if (deep && (entity.ContractChangeCollection.Count > 0))
             {
                 DataRepository.ContractChangeProvider.DeepLoad(transactionManager, entity.ContractChangeCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<ContractCostPlan>", "ContractCostPlanCollection", deepLoadType, innerList))
         {
             entity.ContractCostPlanCollection = DataRepository.ContractCostPlanProvider.GetByContractCode(transactionManager, entity.ContractCode);
             if (deep && (entity.ContractCostPlanCollection.Count > 0))
             {
                 DataRepository.ContractCostPlanProvider.DeepLoad(transactionManager, entity.ContractCostPlanCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<ContractBill>", "ContractBillCollection", deepLoadType, innerList))
         {
             entity.ContractBillCollection = DataRepository.ContractBillProvider.GetByContractCode(transactionManager, entity.ContractCode);
             if (deep && (entity.ContractBillCollection.Count > 0))
             {
                 DataRepository.ContractBillProvider.DeepLoad(transactionManager, entity.ContractBillCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<ContractAccount>", "ContractAccountCollection", deepLoadType, innerList))
         {
             entity.ContractAccountCollection = DataRepository.ContractAccountProvider.GetByContractCode(transactionManager, entity.ContractCode);
             if (deep && (entity.ContractAccountCollection.Count > 0))
             {
                 DataRepository.ContractAccountProvider.DeepLoad(transactionManager, entity.ContractAccountCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<ContractMaterial>", "ContractMaterialCollection", deepLoadType, innerList))
         {
             entity.ContractMaterialCollection = DataRepository.ContractMaterialProvider.GetByContractCode(transactionManager, entity.ContractCode);
             if (deep && (entity.ContractMaterialCollection.Count > 0))
             {
                 DataRepository.ContractMaterialProvider.DeepLoad(transactionManager, entity.ContractMaterialCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
     }
 }
Example #14
0
 internal override void DeepLoad(TransactionManager transactionManager, Trouble entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if ((entity != null) && (base.CanDeepLoad(entity, "InspectSituation", "InspectSituationIDSource", deepLoadType, innerList) && (entity.InspectSituationIDSource == null)))
     {
         object[]         pkItems   = new object[] { entity.InspectSituationID };
         InspectSituation situation = EntityManager.LocateEntity <InspectSituation>(EntityLocator.ConstructKeyFromPkItems(typeof(InspectSituation), pkItems), DataRepository.Provider.EnableEntityTracking);
         if (situation != null)
         {
             entity.InspectSituationIDSource = situation;
         }
         else
         {
             entity.InspectSituationIDSource = DataRepository.InspectSituationProvider.GetByInspectSituationID(entity.InspectSituationID);
         }
         if (deep && (entity.InspectSituationIDSource != null))
         {
             DataRepository.InspectSituationProvider.DeepLoad(transactionManager, entity.InspectSituationIDSource, deep, deepLoadType, childTypes, innerList);
         }
     }
 }