/// <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.OrderStatus"/> 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.OrderStatus 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.OrderStatus entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList) { if (entity == null) { return; } #region OrderIdSource if (CanDeepLoad(entity, "Order|OrderIdSource", deepLoadType, innerList) && entity.OrderIdSource == null) { object[] pkItems = new object[1]; pkItems[0] = entity.OrderId; Order tmpEntity = EntityManager.LocateEntity <Order>(EntityLocator.ConstructKeyFromPkItems(typeof(Order), pkItems), DataRepository.Provider.EnableEntityTracking); if (tmpEntity != null) { entity.OrderIdSource = tmpEntity; } else { entity.OrderIdSource = DataRepository.OrderProvider.GetByOrderId(transactionManager, entity.OrderId); } #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'OrderIdSource' loaded. key " + entity.EntityTrackingKey); #endif if (deep && entity.OrderIdSource != null) { innerList.SkipChildren = true; DataRepository.OrderProvider.DeepLoad(transactionManager, entity.OrderIdSource, deep, deepLoadType, childTypes, innerList); innerList.SkipChildren = false; } } #endregion OrderIdSource //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 Save the entire object graph of the PetShop.Business.Orders object with criteria based of the child /// Type property array and DeepSaveType. /// </summary> /// <param name="transactionManager">The transaction manager.</param> /// <param name="entity">PetShop.Business.Orders instance</param> /// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param> /// <param name="childTypes">PetShop.Business.Orders Property Collection Type Array To Include or Exclude from Save</param> /// <param name="innerList">A Hashtable of child types for easy access.</param> public override bool DeepSave(TransactionManager transactionManager, PetShop.Business.Orders entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList) { if (entity == null) { return(false); } #region Composite Parent Properties //Save Source Composite Properties, however, don't call deep save on them. //So they only get saved a single level deep. #endregion Composite Parent Properties // Save Root Entity through Provider if (!entity.IsDeleted) { this.Save(transactionManager, entity); } //used to hold DeepSave method delegates and fire after all the local children have been saved. Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >(); #region List<LineItem> if (CanDeepSave(entity.LineItemCollection, "List<LineItem>|LineItemCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (LineItem child in entity.LineItemCollection) { if (child.OrderIdSource != null) { child.OrderId = child.OrderIdSource.OrderId; } else { child.OrderId = entity.OrderId; } } if (entity.LineItemCollection.Count > 0 || entity.LineItemCollection.DeletedItems.Count > 0) { //DataRepository.LineItemProvider.Save(transactionManager, entity.LineItemCollection); deepHandles.Add("LineItemCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <LineItem>)DataRepository.LineItemProvider.DeepSave, new object[] { transactionManager, entity.LineItemCollection, deepSaveType, childTypes, innerList } )); } } #endregion #region List<OrderStatus> if (CanDeepSave(entity.OrderStatusCollection, "List<OrderStatus>|OrderStatusCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (OrderStatus child in entity.OrderStatusCollection) { if (child.OrderIdSource != null) { child.OrderId = child.OrderIdSource.OrderId; } else { child.OrderId = entity.OrderId; } } if (entity.OrderStatusCollection.Count > 0 || entity.OrderStatusCollection.DeletedItems.Count > 0) { //DataRepository.OrderStatusProvider.Save(transactionManager, entity.OrderStatusCollection); deepHandles.Add("OrderStatusCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <OrderStatus>)DataRepository.OrderStatusProvider.DeepSave, new object[] { transactionManager, entity.OrderStatusCollection, deepSaveType, childTypes, innerList } )); } } #endregion //Fire all DeepSave Items foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values) { pair.Key.DynamicInvoke((object[])pair.Value); } // Save Root Entity through Provider, if not already saved in delete mode if (entity.IsDeleted) { this.Save(transactionManager, entity); } deepHandles = null; return(true); }
/// <summary> /// Deep Save the entire object graph of the Nettiers.AdventureWorks.Entities.SalesOrderHeaderSalesReason object with criteria based of the child /// Type property array and DeepSaveType. /// </summary> /// <param name="transactionManager">The transaction manager.</param> /// <param name="entity">Nettiers.AdventureWorks.Entities.SalesOrderHeaderSalesReason instance</param> /// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param> /// <param name="childTypes">Nettiers.AdventureWorks.Entities.SalesOrderHeaderSalesReason Property Collection Type Array To Include or Exclude from Save</param> /// <param name="innerList">A Hashtable of child types for easy access.</param> public override bool DeepSave(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.SalesOrderHeaderSalesReason entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList) { if (entity == null) { return(false); } #region Composite Parent Properties //Save Source Composite Properties, however, don't call deep save on them. //So they only get saved a single level deep. #region SalesOrderIdSource if (CanDeepSave(entity, "SalesOrderHeader|SalesOrderIdSource", deepSaveType, innerList) && entity.SalesOrderIdSource != null) { DataRepository.SalesOrderHeaderProvider.Save(transactionManager, entity.SalesOrderIdSource); entity.SalesOrderId = entity.SalesOrderIdSource.SalesOrderId; } #endregion #region SalesReasonIdSource if (CanDeepSave(entity, "SalesReason|SalesReasonIdSource", deepSaveType, innerList) && entity.SalesReasonIdSource != null) { DataRepository.SalesReasonProvider.Save(transactionManager, entity.SalesReasonIdSource); entity.SalesReasonId = entity.SalesReasonIdSource.SalesReasonId; } #endregion #endregion Composite Parent Properties // Save Root Entity through Provider if (!entity.IsDeleted) { this.Save(transactionManager, entity); } //used to hold DeepSave method delegates and fire after all the local children have been saved. Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >(); //Fire all DeepSave Items foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values) { pair.Key.DynamicInvoke((object[])pair.Value); } // Save Root Entity through Provider, if not already saved in delete mode if (entity.IsDeleted) { this.Save(transactionManager, entity); } deepHandles = null; return(true); }
/// <summary> /// Deep Save the entire object graph of the Nettiers.AdventureWorks.Entities.Culture object with criteria based of the child /// Type property array and DeepSaveType. /// </summary> /// <param name="transactionManager">The transaction manager.</param> /// <param name="entity">Nettiers.AdventureWorks.Entities.Culture instance</param> /// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param> /// <param name="childTypes">Nettiers.AdventureWorks.Entities.Culture Property Collection Type Array To Include or Exclude from Save</param> /// <param name="innerList">A Hashtable of child types for easy access.</param> public override bool DeepSave(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.Culture entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList) { if (entity == null) { return(false); } #region Composite Parent Properties //Save Source Composite Properties, however, don't call deep save on them. //So they only get saved a single level deep. #endregion Composite Parent Properties // Save Root Entity through Provider if (!entity.IsDeleted) { this.Save(transactionManager, entity); } //used to hold DeepSave method delegates and fire after all the local children have been saved. Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >(); #region ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture> if (CanDeepSave(entity.ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture, "List<ProductModel>|ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture", deepSaveType, innerList)) { if (entity.ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture.Count > 0 || entity.ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture.DeletedItems.Count > 0) { DataRepository.ProductModelProvider.Save(transactionManager, entity.ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture); deepHandles.Add("ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture", new KeyValuePair <Delegate, object>((DeepSaveHandle <ProductModel>)DataRepository.ProductModelProvider.DeepSave, new object[] { transactionManager, entity.ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture, deepSaveType, childTypes, innerList } )); } } #endregion #region ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture> if (CanDeepSave(entity.ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture, "List<ProductDescription>|ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture", deepSaveType, innerList)) { if (entity.ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture.Count > 0 || entity.ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture.DeletedItems.Count > 0) { DataRepository.ProductDescriptionProvider.Save(transactionManager, entity.ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture); deepHandles.Add("ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture", new KeyValuePair <Delegate, object>((DeepSaveHandle <ProductDescription>)DataRepository.ProductDescriptionProvider.DeepSave, new object[] { transactionManager, entity.ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture, deepSaveType, childTypes, innerList } )); } } #endregion #region List<ProductModelProductDescriptionCulture> if (CanDeepSave(entity.ProductModelProductDescriptionCultureCollection, "List<ProductModelProductDescriptionCulture>|ProductModelProductDescriptionCultureCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (ProductModelProductDescriptionCulture child in entity.ProductModelProductDescriptionCultureCollection) { if (child.CultureIdSource != null) { child.CultureId = child.CultureIdSource.CultureId; } if (child.ProductModelIdSource != null) { child.ProductModelId = child.ProductModelIdSource.ProductModelId; } if (child.ProductDescriptionIdSource != null) { child.ProductDescriptionId = child.ProductDescriptionIdSource.ProductDescriptionId; } } if (entity.ProductModelProductDescriptionCultureCollection.Count > 0 || entity.ProductModelProductDescriptionCultureCollection.DeletedItems.Count > 0) { //DataRepository.ProductModelProductDescriptionCultureProvider.Save(transactionManager, entity.ProductModelProductDescriptionCultureCollection); deepHandles.Add("ProductModelProductDescriptionCultureCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <ProductModelProductDescriptionCulture>)DataRepository.ProductModelProductDescriptionCultureProvider.DeepSave, new object[] { transactionManager, entity.ProductModelProductDescriptionCultureCollection, deepSaveType, childTypes, innerList } )); } } #endregion //Fire all DeepSave Items foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values) { pair.Key.DynamicInvoke((object[])pair.Value); } // Save Root Entity through Provider, if not already saved in delete mode if (entity.IsDeleted) { this.Save(transactionManager, entity); } deepHandles = null; return(true); }
/// <summary> /// Deep Save the entire object graph of the Nettiers.AdventureWorks.Entities.UnitMeasure object with criteria based of the child /// Type property array and DeepSaveType. /// </summary> /// <param name="transactionManager">The transaction manager.</param> /// <param name="entity">Nettiers.AdventureWorks.Entities.UnitMeasure instance</param> /// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param> /// <param name="childTypes">Nettiers.AdventureWorks.Entities.UnitMeasure Property Collection Type Array To Include or Exclude from Save</param> /// <param name="innerList">A Hashtable of child types for easy access.</param> public override bool DeepSave(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.UnitMeasure entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList) { if (entity == null) { return(false); } #region Composite Parent Properties //Save Source Composite Properties, however, don't call deep save on them. //So they only get saved a single level deep. #endregion Composite Parent Properties // Save Root Entity through Provider if (!entity.IsDeleted) { this.Save(transactionManager, entity); } //used to hold DeepSave method delegates and fire after all the local children have been saved. Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >(); #region List<BillOfMaterials> if (CanDeepSave(entity.BillOfMaterialsCollection, "List<BillOfMaterials>|BillOfMaterialsCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (BillOfMaterials child in entity.BillOfMaterialsCollection) { if (child.UnitMeasureCodeSource != null) { child.UnitMeasureCode = child.UnitMeasureCodeSource.UnitMeasureCode; } else { child.UnitMeasureCode = entity.UnitMeasureCode; } } if (entity.BillOfMaterialsCollection.Count > 0 || entity.BillOfMaterialsCollection.DeletedItems.Count > 0) { //DataRepository.BillOfMaterialsProvider.Save(transactionManager, entity.BillOfMaterialsCollection); deepHandles.Add("BillOfMaterialsCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <BillOfMaterials>)DataRepository.BillOfMaterialsProvider.DeepSave, new object[] { transactionManager, entity.BillOfMaterialsCollection, deepSaveType, childTypes, innerList } )); } } #endregion #region List<Product> if (CanDeepSave(entity.ProductCollectionGetByWeightUnitMeasureCode, "List<Product>|ProductCollectionGetByWeightUnitMeasureCode", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (Product child in entity.ProductCollectionGetByWeightUnitMeasureCode) { if (child.WeightUnitMeasureCodeSource != null) { child.WeightUnitMeasureCode = child.WeightUnitMeasureCodeSource.UnitMeasureCode; } else { child.WeightUnitMeasureCode = entity.UnitMeasureCode; } } if (entity.ProductCollectionGetByWeightUnitMeasureCode.Count > 0 || entity.ProductCollectionGetByWeightUnitMeasureCode.DeletedItems.Count > 0) { //DataRepository.ProductProvider.Save(transactionManager, entity.ProductCollectionGetByWeightUnitMeasureCode); deepHandles.Add("ProductCollectionGetByWeightUnitMeasureCode", new KeyValuePair <Delegate, object>((DeepSaveHandle <Product>)DataRepository.ProductProvider.DeepSave, new object[] { transactionManager, entity.ProductCollectionGetByWeightUnitMeasureCode, deepSaveType, childTypes, innerList } )); } } #endregion #region List<ProductVendor> if (CanDeepSave(entity.ProductVendorCollection, "List<ProductVendor>|ProductVendorCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (ProductVendor child in entity.ProductVendorCollection) { } if (entity.ProductVendorCollection.Count > 0 || entity.ProductVendorCollection.DeletedItems.Count > 0) { //DataRepository.ProductVendorProvider.Save(transactionManager, entity.ProductVendorCollection); deepHandles.Add("ProductVendorCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <ProductVendor>)DataRepository.ProductVendorProvider.DeepSave, new object[] { transactionManager, entity.ProductVendorCollection, deepSaveType, childTypes, innerList } )); } } #endregion #region List<Product> if (CanDeepSave(entity.ProductCollectionGetBySizeUnitMeasureCode, "List<Product>|ProductCollectionGetBySizeUnitMeasureCode", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (Product child in entity.ProductCollectionGetBySizeUnitMeasureCode) { if (child.SizeUnitMeasureCodeSource != null) { child.SizeUnitMeasureCode = child.SizeUnitMeasureCodeSource.UnitMeasureCode; } else { child.SizeUnitMeasureCode = entity.UnitMeasureCode; } } if (entity.ProductCollectionGetBySizeUnitMeasureCode.Count > 0 || entity.ProductCollectionGetBySizeUnitMeasureCode.DeletedItems.Count > 0) { //DataRepository.ProductProvider.Save(transactionManager, entity.ProductCollectionGetBySizeUnitMeasureCode); deepHandles.Add("ProductCollectionGetBySizeUnitMeasureCode", new KeyValuePair <Delegate, object>((DeepSaveHandle <Product>)DataRepository.ProductProvider.DeepSave, new object[] { transactionManager, entity.ProductCollectionGetBySizeUnitMeasureCode, deepSaveType, childTypes, innerList } )); } } #endregion //Fire all DeepSave Items foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values) { pair.Key.DynamicInvoke((object[])pair.Value); } // Save Root Entity through Provider, if not already saved in delete mode if (entity.IsDeleted) { this.Save(transactionManager, entity); } deepHandles = null; return(true); }
/// <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.TransValue"/> 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.TransValue 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.TransValue 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; }
/// <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.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; }
/// <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; }
/// <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.Employee"/> 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.Employee 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.Employee 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 GetByEmployeeId 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.GetByEmployeeId(transactionManager, entity.EmployeeId); 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 #region EmployeeDepartmentsCollection //Relationship Type One : Many if (CanDeepLoad(entity, "List<EmployeeDepartments>|EmployeeDepartmentsCollection", deepLoadType, innerList)) { #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'EmployeeDepartmentsCollection' loaded. key " + entity.EntityTrackingKey); #endif entity.EmployeeDepartmentsCollection = DataRepository.EmployeeDepartmentsProvider.GetByEmployeeId(transactionManager, entity.EmployeeId); if (deep && entity.EmployeeDepartmentsCollection.Count > 0) { deepHandles.Add("EmployeeDepartmentsCollection", new KeyValuePair <Delegate, object>((DeepLoadHandle <EmployeeDepartments>)DataRepository.EmployeeDepartmentsProvider.DeepLoad, new object[] { transactionManager, entity.EmployeeDepartmentsCollection, deep, deepLoadType, childTypes, innerList } )); } } #endregion #region EmployeeSalaryCollection //Relationship Type One : Many if (CanDeepLoad(entity, "List<EmployeeSalary>|EmployeeSalaryCollection", deepLoadType, innerList)) { #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'EmployeeSalaryCollection' loaded. key " + entity.EntityTrackingKey); #endif entity.EmployeeSalaryCollection = DataRepository.EmployeeSalaryProvider.GetByEmployeeId(transactionManager, entity.EmployeeId); if (deep && entity.EmployeeSalaryCollection.Count > 0) { deepHandles.Add("EmployeeSalaryCollection", new KeyValuePair <Delegate, object>((DeepLoadHandle <EmployeeSalary>)DataRepository.EmployeeSalaryProvider.DeepLoad, new object[] { transactionManager, entity.EmployeeSalaryCollection, deep, deepLoadType, childTypes, innerList } )); } } #endregion #region AddressCollection //Relationship Type One : Many if (CanDeepLoad(entity, "List<Address>|AddressCollection", deepLoadType, innerList)) { #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'AddressCollection' loaded. key " + entity.EntityTrackingKey); #endif entity.AddressCollection = DataRepository.AddressProvider.GetByEmployeeId(transactionManager, entity.EmployeeId); if (deep && entity.AddressCollection.Count > 0) { deepHandles.Add("AddressCollection", new KeyValuePair <Delegate, object>((DeepLoadHandle <Address>)DataRepository.AddressProvider.DeepLoad, new object[] { transactionManager, entity.AddressCollection, deep, deepLoadType, childTypes, innerList } )); } } #endregion #region BankAccountsCollection //Relationship Type One : Many if (CanDeepLoad(entity, "List<BankAccounts>|BankAccountsCollection", deepLoadType, innerList)) { #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'BankAccountsCollection' loaded. key " + entity.EntityTrackingKey); #endif entity.BankAccountsCollection = DataRepository.BankAccountsProvider.GetByEmployeeId(transactionManager, entity.EmployeeId); if (deep && entity.BankAccountsCollection.Count > 0) { deepHandles.Add("BankAccountsCollection", new KeyValuePair <Delegate, object>((DeepLoadHandle <BankAccounts>)DataRepository.BankAccountsProvider.DeepLoad, new object[] { transactionManager, entity.BankAccountsCollection, 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 Save the entire object graph of the EmployeeDB.BLL.Employee object with criteria based of the child /// Type property array and DeepSaveType. /// </summary> /// <param name="transactionManager">The transaction manager.</param> /// <param name="entity">EmployeeDB.BLL.Employee instance</param> /// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param> /// <param name="childTypes">EmployeeDB.BLL.Employee Property Collection Type Array To Include or Exclude from Save</param> /// <param name="innerList">A Hashtable of child types for easy access.</param> public override bool DeepSave(TransactionManager transactionManager, EmployeeDB.BLL.Employee entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList) { if (entity == null) { return(false); } #region Composite Parent Properties //Save Source Composite Properties, however, don't call deep save on them. //So they only get saved a single level deep. #endregion Composite Parent Properties // Save Root Entity through Provider if (!entity.IsDeleted) { this.Save(transactionManager, entity); } //used to hold DeepSave method delegates and fire after all the local children have been saved. Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >(); #region List<EmployeeSkills> if (CanDeepSave(entity.EmployeeSkillsCollection, "List<EmployeeSkills>|EmployeeSkillsCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (EmployeeSkills child in entity.EmployeeSkillsCollection) { if (child.EmployeeIdSource != null) { child.EmployeeId = child.EmployeeIdSource.EmployeeId; } else { child.EmployeeId = entity.EmployeeId; } } if (entity.EmployeeSkillsCollection.Count > 0 || entity.EmployeeSkillsCollection.DeletedItems.Count > 0) { //DataRepository.EmployeeSkillsProvider.Save(transactionManager, entity.EmployeeSkillsCollection); deepHandles.Add("EmployeeSkillsCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <EmployeeSkills>)DataRepository.EmployeeSkillsProvider.DeepSave, new object[] { transactionManager, entity.EmployeeSkillsCollection, deepSaveType, childTypes, innerList } )); } } #endregion #region List<EmployeeDepartments> if (CanDeepSave(entity.EmployeeDepartmentsCollection, "List<EmployeeDepartments>|EmployeeDepartmentsCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (EmployeeDepartments child in entity.EmployeeDepartmentsCollection) { if (child.EmployeeIdSource != null) { child.EmployeeId = child.EmployeeIdSource.EmployeeId; } else { child.EmployeeId = entity.EmployeeId; } } if (entity.EmployeeDepartmentsCollection.Count > 0 || entity.EmployeeDepartmentsCollection.DeletedItems.Count > 0) { //DataRepository.EmployeeDepartmentsProvider.Save(transactionManager, entity.EmployeeDepartmentsCollection); deepHandles.Add("EmployeeDepartmentsCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <EmployeeDepartments>)DataRepository.EmployeeDepartmentsProvider.DeepSave, new object[] { transactionManager, entity.EmployeeDepartmentsCollection, deepSaveType, childTypes, innerList } )); } } #endregion #region List<EmployeeSalary> if (CanDeepSave(entity.EmployeeSalaryCollection, "List<EmployeeSalary>|EmployeeSalaryCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (EmployeeSalary child in entity.EmployeeSalaryCollection) { if (child.EmployeeIdSource != null) { child.EmployeeId = child.EmployeeIdSource.EmployeeId; } else { child.EmployeeId = entity.EmployeeId; } } if (entity.EmployeeSalaryCollection.Count > 0 || entity.EmployeeSalaryCollection.DeletedItems.Count > 0) { //DataRepository.EmployeeSalaryProvider.Save(transactionManager, entity.EmployeeSalaryCollection); deepHandles.Add("EmployeeSalaryCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <EmployeeSalary>)DataRepository.EmployeeSalaryProvider.DeepSave, new object[] { transactionManager, entity.EmployeeSalaryCollection, deepSaveType, childTypes, innerList } )); } } #endregion #region List<Address> if (CanDeepSave(entity.AddressCollection, "List<Address>|AddressCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (Address child in entity.AddressCollection) { if (child.EmployeeIdSource != null) { child.EmployeeId = child.EmployeeIdSource.EmployeeId; } else { child.EmployeeId = entity.EmployeeId; } } if (entity.AddressCollection.Count > 0 || entity.AddressCollection.DeletedItems.Count > 0) { //DataRepository.AddressProvider.Save(transactionManager, entity.AddressCollection); deepHandles.Add("AddressCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <Address>)DataRepository.AddressProvider.DeepSave, new object[] { transactionManager, entity.AddressCollection, deepSaveType, childTypes, innerList } )); } } #endregion #region List<BankAccounts> if (CanDeepSave(entity.BankAccountsCollection, "List<BankAccounts>|BankAccountsCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (BankAccounts child in entity.BankAccountsCollection) { if (child.EmployeeIdSource != null) { child.EmployeeId = child.EmployeeIdSource.EmployeeId; } else { child.EmployeeId = entity.EmployeeId; } } if (entity.BankAccountsCollection.Count > 0 || entity.BankAccountsCollection.DeletedItems.Count > 0) { //DataRepository.BankAccountsProvider.Save(transactionManager, entity.BankAccountsCollection); deepHandles.Add("BankAccountsCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <BankAccounts>)DataRepository.BankAccountsProvider.DeepSave, new object[] { transactionManager, entity.BankAccountsCollection, deepSaveType, childTypes, innerList } )); } } #endregion //Fire all DeepSave Items foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values) { pair.Key.DynamicInvoke((object[])pair.Value); } // Save Root Entity through Provider, if not already saved in delete mode if (entity.IsDeleted) { this.Save(transactionManager, entity); } deepHandles = null; return(true); }
/// <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 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(); }
/// <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; }
/// <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.Specchietto"/> 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.Specchietto 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.Specchietto entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList) { if (entity == null) { return; } #region AggregationMacchinaIDSource if (CanDeepLoad(entity, "Macchina|AggregationMacchinaIDSource", deepLoadType, innerList) && entity.AggregationMacchinaIDSource == null) { object[] pkItems = new object[1]; pkItems[0] = (entity.AggregationMacchinaID ?? (int)0); Macchina tmpEntity = EntityManager.LocateEntity <Macchina>(EntityLocator.ConstructKeyFromPkItems(typeof(Macchina), pkItems), DataRepository.Provider.EnableEntityTracking); if (tmpEntity != null) { entity.AggregationMacchinaIDSource = tmpEntity; } else { entity.AggregationMacchinaIDSource = DataRepository.MacchinaProvider.GetByID(transactionManager, (entity.AggregationMacchinaID ?? (int)0)); } #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'AggregationMacchinaIDSource' loaded. key " + entity.EntityTrackingKey); #endif if (deep && entity.AggregationMacchinaIDSource != null) { innerList.SkipChildren = true; DataRepository.MacchinaProvider.DeepLoad(transactionManager, entity.AggregationMacchinaIDSource, deep, deepLoadType, childTypes, innerList); innerList.SkipChildren = false; } } #endregion AggregationMacchinaIDSource #region SgutAssociationSpecchiettoIDSource if (CanDeepLoad(entity, "Specchietto|SgutAssociationSpecchiettoIDSource", deepLoadType, innerList) && entity.SgutAssociationSpecchiettoIDSource == null) { object[] pkItems = new object[1]; pkItems[0] = (entity.SgutAssociationSpecchiettoID ?? (int)0); Specchietto tmpEntity = EntityManager.LocateEntity <Specchietto>(EntityLocator.ConstructKeyFromPkItems(typeof(Specchietto), pkItems), DataRepository.Provider.EnableEntityTracking); if (tmpEntity != null) { entity.SgutAssociationSpecchiettoIDSource = tmpEntity; } else { entity.SgutAssociationSpecchiettoIDSource = DataRepository.SpecchiettoProvider.GetByID(transactionManager, (entity.SgutAssociationSpecchiettoID ?? (int)0)); } #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'SgutAssociationSpecchiettoIDSource' loaded. key " + entity.EntityTrackingKey); #endif if (deep && entity.SgutAssociationSpecchiettoIDSource != null) { innerList.SkipChildren = true; DataRepository.SpecchiettoProvider.DeepLoad(transactionManager, entity.SgutAssociationSpecchiettoIDSource, deep, deepLoadType, childTypes, innerList); innerList.SkipChildren = false; } } #endregion SgutAssociationSpecchiettoIDSource #region AssociationSpecchiettoIDSource if (CanDeepLoad(entity, "Specchietto|AssociationSpecchiettoIDSource", deepLoadType, innerList) && entity.AssociationSpecchiettoIDSource == null) { object[] pkItems = new object[1]; pkItems[0] = (entity.AssociationSpecchiettoID ?? (int)0); Specchietto tmpEntity = EntityManager.LocateEntity <Specchietto>(EntityLocator.ConstructKeyFromPkItems(typeof(Specchietto), pkItems), DataRepository.Provider.EnableEntityTracking); if (tmpEntity != null) { entity.AssociationSpecchiettoIDSource = tmpEntity; } else { entity.AssociationSpecchiettoIDSource = DataRepository.SpecchiettoProvider.GetByID(transactionManager, (entity.AssociationSpecchiettoID ?? (int)0)); } #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'AssociationSpecchiettoIDSource' loaded. key " + entity.EntityTrackingKey); #endif if (deep && entity.AssociationSpecchiettoIDSource != null) { innerList.SkipChildren = true; DataRepository.SpecchiettoProvider.DeepLoad(transactionManager, entity.AssociationSpecchiettoIDSource, deep, deepLoadType, childTypes, innerList); innerList.SkipChildren = false; } } #endregion AssociationSpecchiettoIDSource //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 SpecchiettoGetBySgutAssociationSpecchiettoID // RelationshipType.OneToOne if (CanDeepLoad(entity, "Specchietto|SpecchiettoGetBySgutAssociationSpecchiettoID", deepLoadType, innerList)) { entity.SpecchiettoGetBySgutAssociationSpecchiettoID = DataRepository.SpecchiettoProvider.GetBySgutAssociationSpecchiettoID(transactionManager, entity.ID); #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'SpecchiettoGetBySgutAssociationSpecchiettoID' loaded. key " + entity.EntityTrackingKey); #endif if (deep && entity.SpecchiettoGetBySgutAssociationSpecchiettoID != null) { deepHandles.Add("SpecchiettoGetBySgutAssociationSpecchiettoID", new KeyValuePair <Delegate, object>((DeepLoadSingleHandle <Specchietto>)DataRepository.SpecchiettoProvider.DeepLoad, new object[] { transactionManager, entity.SpecchiettoGetBySgutAssociationSpecchiettoID, deep, deepLoadType, childTypes, innerList } )); } } #endregion #region SpecchiettoGetByAssociationSpecchiettoID // RelationshipType.OneToOne if (CanDeepLoad(entity, "Specchietto|SpecchiettoGetByAssociationSpecchiettoID", deepLoadType, innerList)) { entity.SpecchiettoGetByAssociationSpecchiettoID = DataRepository.SpecchiettoProvider.GetByAssociationSpecchiettoID(transactionManager, entity.ID); #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'SpecchiettoGetByAssociationSpecchiettoID' loaded. key " + entity.EntityTrackingKey); #endif if (deep && entity.SpecchiettoGetByAssociationSpecchiettoID != null) { deepHandles.Add("SpecchiettoGetByAssociationSpecchiettoID", new KeyValuePair <Delegate, object>((DeepLoadSingleHandle <Specchietto>)DataRepository.SpecchiettoProvider.DeepLoad, new object[] { transactionManager, entity.SpecchiettoGetByAssociationSpecchiettoID, 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 Save the entire object graph of the Nettiers.AdventureWorks.Entities.SalesTerritory object with criteria based of the child /// Type property array and DeepSaveType. /// </summary> /// <param name="transactionManager">The transaction manager.</param> /// <param name="entity">Nettiers.AdventureWorks.Entities.SalesTerritory instance</param> /// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param> /// <param name="childTypes">Nettiers.AdventureWorks.Entities.SalesTerritory Property Collection Type Array To Include or Exclude from Save</param> /// <param name="innerList">A Hashtable of child types for easy access.</param> public override bool DeepSave(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.SalesTerritory entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList) { if (entity == null) { return(false); } #region Composite Parent Properties //Save Source Composite Properties, however, don't call deep save on them. //So they only get saved a single level deep. #endregion Composite Parent Properties // Save Root Entity through Provider if (!entity.IsDeleted) { this.Save(transactionManager, entity); } //used to hold DeepSave method delegates and fire after all the local children have been saved. Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >(); #region List<StateProvince> if (CanDeepSave(entity.StateProvinceCollection, "List<StateProvince>|StateProvinceCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (StateProvince child in entity.StateProvinceCollection) { if (child.TerritoryIdSource != null) { child.TerritoryId = child.TerritoryIdSource.TerritoryId; } else { child.TerritoryId = entity.TerritoryId; } } if (entity.StateProvinceCollection.Count > 0 || entity.StateProvinceCollection.DeletedItems.Count > 0) { //DataRepository.StateProvinceProvider.Save(transactionManager, entity.StateProvinceCollection); deepHandles.Add("StateProvinceCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <StateProvince>)DataRepository.StateProvinceProvider.DeepSave, new object[] { transactionManager, entity.StateProvinceCollection, deepSaveType, childTypes, innerList } )); } } #endregion #region List<SalesOrderHeader> if (CanDeepSave(entity.SalesOrderHeaderCollection, "List<SalesOrderHeader>|SalesOrderHeaderCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (SalesOrderHeader child in entity.SalesOrderHeaderCollection) { if (child.TerritoryIdSource != null) { child.TerritoryId = child.TerritoryIdSource.TerritoryId; } else { child.TerritoryId = entity.TerritoryId; } } if (entity.SalesOrderHeaderCollection.Count > 0 || entity.SalesOrderHeaderCollection.DeletedItems.Count > 0) { //DataRepository.SalesOrderHeaderProvider.Save(transactionManager, entity.SalesOrderHeaderCollection); deepHandles.Add("SalesOrderHeaderCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <SalesOrderHeader>)DataRepository.SalesOrderHeaderProvider.DeepSave, new object[] { transactionManager, entity.SalesOrderHeaderCollection, deepSaveType, childTypes, innerList } )); } } #endregion #region List<SalesPerson> if (CanDeepSave(entity.SalesPersonCollection, "List<SalesPerson>|SalesPersonCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (SalesPerson child in entity.SalesPersonCollection) { if (child.TerritoryIdSource != null) { child.TerritoryId = child.TerritoryIdSource.TerritoryId; } else { child.TerritoryId = entity.TerritoryId; } } if (entity.SalesPersonCollection.Count > 0 || entity.SalesPersonCollection.DeletedItems.Count > 0) { //DataRepository.SalesPersonProvider.Save(transactionManager, entity.SalesPersonCollection); deepHandles.Add("SalesPersonCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <SalesPerson>)DataRepository.SalesPersonProvider.DeepSave, new object[] { transactionManager, entity.SalesPersonCollection, deepSaveType, childTypes, innerList } )); } } #endregion #region List<SalesTerritoryHistory> if (CanDeepSave(entity.SalesTerritoryHistoryCollection, "List<SalesTerritoryHistory>|SalesTerritoryHistoryCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (SalesTerritoryHistory child in entity.SalesTerritoryHistoryCollection) { if (child.TerritoryIdSource != null) { child.TerritoryId = child.TerritoryIdSource.TerritoryId; } else { child.TerritoryId = entity.TerritoryId; } } if (entity.SalesTerritoryHistoryCollection.Count > 0 || entity.SalesTerritoryHistoryCollection.DeletedItems.Count > 0) { //DataRepository.SalesTerritoryHistoryProvider.Save(transactionManager, entity.SalesTerritoryHistoryCollection); deepHandles.Add("SalesTerritoryHistoryCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <SalesTerritoryHistory>)DataRepository.SalesTerritoryHistoryProvider.DeepSave, new object[] { transactionManager, entity.SalesTerritoryHistoryCollection, deepSaveType, childTypes, innerList } )); } } #endregion #region List<Customer> if (CanDeepSave(entity.CustomerCollection, "List<Customer>|CustomerCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (Customer child in entity.CustomerCollection) { if (child.TerritoryIdSource != null) { child.TerritoryId = child.TerritoryIdSource.TerritoryId; } else { child.TerritoryId = entity.TerritoryId; } } if (entity.CustomerCollection.Count > 0 || entity.CustomerCollection.DeletedItems.Count > 0) { //DataRepository.CustomerProvider.Save(transactionManager, entity.CustomerCollection); deepHandles.Add("CustomerCollection", new KeyValuePair <Delegate, object>((DeepSaveHandle <Customer>)DataRepository.CustomerProvider.DeepSave, new object[] { transactionManager, entity.CustomerCollection, deepSaveType, childTypes, innerList } )); } } #endregion //Fire all DeepSave Items foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values) { pair.Key.DynamicInvoke((object[])pair.Value); } // Save Root Entity through Provider, if not already saved in delete mode if (entity.IsDeleted) { this.Save(transactionManager, entity); } deepHandles = null; return(true); }
/// <summary> /// Deep Save the entire object graph of the GenTest.Entities.Specchietto object with criteria based of the child /// Type property array and DeepSaveType. /// </summary> /// <param name="transactionManager">The transaction manager.</param> /// <param name="entity">GenTest.Entities.Specchietto instance</param> /// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param> /// <param name="childTypes">GenTest.Entities.Specchietto Property Collection Type Array To Include or Exclude from Save</param> /// <param name="innerList">A Hashtable of child types for easy access.</param> public override bool DeepSave(TransactionManager transactionManager, GenTest.Entities.Specchietto entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList) { if (entity == null) { return(false); } #region Composite Parent Properties //Save Source Composite Properties, however, don't call deep save on them. //So they only get saved a single level deep. #region AggregationMacchinaIDSource if (CanDeepSave(entity, "Macchina|AggregationMacchinaIDSource", deepSaveType, innerList) && entity.AggregationMacchinaIDSource != null) { DataRepository.MacchinaProvider.Save(transactionManager, entity.AggregationMacchinaIDSource); entity.AggregationMacchinaID = entity.AggregationMacchinaIDSource.ID; } #endregion #region SgutAssociationSpecchiettoIDSource if (CanDeepSave(entity, "Specchietto|SgutAssociationSpecchiettoIDSource", deepSaveType, innerList) && entity.SgutAssociationSpecchiettoIDSource != null) { DataRepository.SpecchiettoProvider.Save(transactionManager, entity.SgutAssociationSpecchiettoIDSource); entity.SgutAssociationSpecchiettoID = entity.SgutAssociationSpecchiettoIDSource.ID; } #endregion #region AssociationSpecchiettoIDSource if (CanDeepSave(entity, "Specchietto|AssociationSpecchiettoIDSource", deepSaveType, innerList) && entity.AssociationSpecchiettoIDSource != null) { DataRepository.SpecchiettoProvider.Save(transactionManager, entity.AssociationSpecchiettoIDSource); entity.AssociationSpecchiettoID = entity.AssociationSpecchiettoIDSource.ID; } #endregion #endregion Composite Parent Properties // Save Root Entity through Provider if (!entity.IsDeleted) { this.Save(transactionManager, entity); } //used to hold DeepSave method delegates and fire after all the local children have been saved. Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >(); #region SpecchiettoGetBySgutAssociationSpecchiettoID if (CanDeepSave(entity.SpecchiettoGetBySgutAssociationSpecchiettoID, "Specchietto|SpecchiettoGetBySgutAssociationSpecchiettoID", deepSaveType, innerList)) { if (entity.SpecchiettoGetBySgutAssociationSpecchiettoID != null) { // update each child parent id with the real parent id (mostly used on insert) entity.Specchietto.SgutAssociationSpecchiettoID = entity.ID; //DataRepository.SpecchiettoProvider.Save(transactionManager, entity.SpecchiettoGetBySgutAssociationSpecchiettoID); deepHandles.Add("SpecchiettoGetBySgutAssociationSpecchiettoID", new KeyValuePair <Delegate, object>((DeepSaveSingleHandle <Specchietto>)DataRepository.SpecchiettoProvider.DeepSave, new object[] { transactionManager, entity.SpecchiettoGetBySgutAssociationSpecchiettoID, deepSaveType, childTypes, innerList } )); } } #endregion #region SpecchiettoGetByAssociationSpecchiettoID if (CanDeepSave(entity.SpecchiettoGetByAssociationSpecchiettoID, "Specchietto|SpecchiettoGetByAssociationSpecchiettoID", deepSaveType, innerList)) { if (entity.SpecchiettoGetByAssociationSpecchiettoID != null) { // update each child parent id with the real parent id (mostly used on insert) entity.Specchietto.AssociationSpecchiettoID = entity.ID; //DataRepository.SpecchiettoProvider.Save(transactionManager, entity.SpecchiettoGetByAssociationSpecchiettoID); deepHandles.Add("SpecchiettoGetByAssociationSpecchiettoID", new KeyValuePair <Delegate, object>((DeepSaveSingleHandle <Specchietto>)DataRepository.SpecchiettoProvider.DeepSave, new object[] { transactionManager, entity.SpecchiettoGetByAssociationSpecchiettoID, deepSaveType, childTypes, innerList } )); } } #endregion //Fire all DeepSave Items foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values) { pair.Key.DynamicInvoke((object[])pair.Value); } // Save Root Entity through Provider, if not already saved in delete mode if (entity.IsDeleted) { this.Save(transactionManager, entity); } deepHandles = null; return(true); }
/// <summary> /// Deep Save the entire object graph of the GenTest.Entities.RigaFattura object with criteria based of the child /// Type property array and DeepSaveType. /// </summary> /// <param name="transactionManager">The transaction manager.</param> /// <param name="entity">GenTest.Entities.RigaFattura instance</param> /// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param> /// <param name="childTypes">GenTest.Entities.RigaFattura Property Collection Type Array To Include or Exclude from Save</param> /// <param name="innerList">A Hashtable of child types for easy access.</param> internal override bool DeepSave(TransactionManager transactionManager, GenTest.Entities.RigaFattura entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList) { if (entity == null) { return(false); } #region Composite Parent Properties //Save Source Composite Properties, however, don't call deep save on them. //So they only get saved a single level deep. #region ComposedFatturaIDSource if (CanDeepSave(entity, "Fattura|ComposedFatturaIDSource", deepSaveType, innerList) && entity.ComposedFatturaIDSource != null) { DataRepository.FatturaProvider.Save(transactionManager, entity.ComposedFatturaIDSource); entity.ComposedFatturaID = entity.ComposedFatturaIDSource.ID; } #endregion #region AggregatedFatturaIDSource if (CanDeepSave(entity, "Fattura|AggregatedFatturaIDSource", deepSaveType, innerList) && entity.AggregatedFatturaIDSource != null) { DataRepository.FatturaProvider.Save(transactionManager, entity.AggregatedFatturaIDSource); entity.AggregatedFatturaID = entity.AggregatedFatturaIDSource.ID; } #endregion #region AssociatedFatturaIDSource if (CanDeepSave(entity, "Fattura|AssociatedFatturaIDSource", deepSaveType, innerList) && entity.AssociatedFatturaIDSource != null) { DataRepository.FatturaProvider.Save(transactionManager, entity.AssociatedFatturaIDSource); entity.AssociatedFatturaID = entity.AssociatedFatturaIDSource.ID; } #endregion #endregion Composite Parent Properties // Save Root Entity through Provider if (!entity.IsDeleted) { this.Save(transactionManager, entity); } //used to hold DeepSave method delegates and fire after all the local children have been saved. Dictionary <Delegate, object> deepHandles = new Dictionary <Delegate, object>(); #region Fattura if (CanDeepSave(entity.Fattura, "Fattura|Fattura", deepSaveType, innerList)) { if (entity.Fattura != null) { // update each child parent id with the real parent id (mostly used on insert) entity.Fattura.AssociatedRigaFatturaID = entity.ID; DataRepository.FatturaProvider.Save(transactionManager, entity.Fattura); deepHandles.Add( (DeepSaveSingleHandle <Fattura>)DataRepository.FatturaProvider.DeepSave, new object[] { transactionManager, entity.Fattura, deepSaveType, childTypes, innerList } ); } } #endregion #region List<Fattura> if (CanDeepSave(entity.FatturaCollectionGetByAggregatedRigaFatturaID, "List<Fattura>|FatturaCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (Fattura child in entity.FatturaCollectionGetByAggregatedRigaFatturaID) { if (child.AggregatedRigaFatturaIDSource != null) { child.AggregatedRigaFatturaID = child.AggregatedRigaFatturaIDSource.ID; } else { child.AggregatedRigaFatturaID = entity.ID; } } if (entity.FatturaCollectionGetByAggregatedRigaFatturaID.Count > 0 || entity.FatturaCollectionGetByAggregatedRigaFatturaID.DeletedItems.Count > 0) { DataRepository.FatturaProvider.Save(transactionManager, entity.FatturaCollectionGetByAggregatedRigaFatturaID); deepHandles.Add( (DeepSaveHandle <Fattura>)DataRepository.FatturaProvider.DeepSave, new object[] { transactionManager, entity.FatturaCollectionGetByAggregatedRigaFatturaID, deepSaveType, childTypes, innerList } ); } } #endregion #region List<Fattura> if (CanDeepSave(entity.FatturaCollectionGetByComposedRigaFatturaID, "List<Fattura>|FatturaCollection", deepSaveType, innerList)) { // update each child parent id with the real parent id (mostly used on insert) foreach (Fattura child in entity.FatturaCollectionGetByComposedRigaFatturaID) { if (child.ComposedRigaFatturaIDSource != null) { child.ComposedRigaFatturaID = child.ComposedRigaFatturaIDSource.ID; } else { child.ComposedRigaFatturaID = entity.ID; } } if (entity.FatturaCollectionGetByComposedRigaFatturaID.Count > 0 || entity.FatturaCollectionGetByComposedRigaFatturaID.DeletedItems.Count > 0) { DataRepository.FatturaProvider.Save(transactionManager, entity.FatturaCollectionGetByComposedRigaFatturaID); deepHandles.Add( (DeepSaveHandle <Fattura>)DataRepository.FatturaProvider.DeepSave, new object[] { transactionManager, entity.FatturaCollectionGetByComposedRigaFatturaID, deepSaveType, childTypes, innerList } ); } } #endregion //Fire all DeepSave Items foreach (KeyValuePair <Delegate, object> pair in deepHandles) { pair.Key.DynamicInvoke((object[])pair.Value); } // Save Root Entity through Provider, if not already saved in delete mode if (entity.IsDeleted) { this.Save(transactionManager, entity); } deepHandles = null; return(true); }
/// <summary> /// Deep Save the entire object graph of the LibraryManagement.Domain.TransValue object with criteria based of the child /// Type property array and DeepSaveType. /// </summary> /// <param name="transactionManager">The transaction manager.</param> /// <param name="entity">LibraryManagement.Domain.TransValue instance</param> /// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param> /// <param name="childTypes">LibraryManagement.Domain.TransValue Property Collection Type Array To Include or Exclude from Save</param> /// <param name="innerList">A Hashtable of child types for easy access.</param> public override bool DeepSave(TransactionManager transactionManager, LibraryManagement.Domain.TransValue entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList) { if (entity == null) { return(false); } #region Composite Parent Properties //Save Source Composite Properties, however, don't call deep save on them. //So they only get saved a single level deep. #endregion Composite Parent Properties // Save Root Entity through Provider if (!entity.IsDeleted) { this.Save(transactionManager, entity); } //used to hold DeepSave method delegates and fire after all the local children have been saved. Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >(); //Fire all DeepSave Items foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values) { pair.Key.DynamicInvoke((object[])pair.Value); } // Save Root Entity through Provider, if not already saved in delete mode if (entity.IsDeleted) { this.Save(transactionManager, entity); } deepHandles = null; return(true); }
/// <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.CreditCard"/> 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.CreditCard 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.CreditCard 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 GetByCreditCardId methods when available #region ContactCreditCardCollection //Relationship Type One : Many if (CanDeepLoad(entity, "List<ContactCreditCard>|ContactCreditCardCollection", deepLoadType, innerList)) { #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'ContactCreditCardCollection' loaded. key " + entity.EntityTrackingKey); #endif entity.ContactCreditCardCollection = DataRepository.ContactCreditCardProvider.GetByCreditCardId(transactionManager, entity.CreditCardId); if (deep && entity.ContactCreditCardCollection.Count > 0) { deepHandles.Add("ContactCreditCardCollection", new KeyValuePair <Delegate, object>((DeepLoadHandle <ContactCreditCard>)DataRepository.ContactCreditCardProvider.DeepLoad, new object[] { transactionManager, entity.ContactCreditCardCollection, deep, deepLoadType, childTypes, innerList } )); } } #endregion #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.GetByCreditCardId(transactionManager, entity.CreditCardId); 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 #region ContactIdContactCollection_From_ContactCreditCard // RelationshipType.ManyToMany if (CanDeepLoad(entity, "List<Contact>|ContactIdContactCollection_From_ContactCreditCard", deepLoadType, innerList)) { entity.ContactIdContactCollection_From_ContactCreditCard = DataRepository.ContactProvider.GetByCreditCardIdFromContactCreditCard(transactionManager, entity.CreditCardId); #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'ContactIdContactCollection_From_ContactCreditCard' loaded. key " + entity.EntityTrackingKey); #endif if (deep && entity.ContactIdContactCollection_From_ContactCreditCard != null) { deepHandles.Add("ContactIdContactCollection_From_ContactCreditCard", new KeyValuePair <Delegate, object>((DeepLoadHandle <Contact>)DataRepository.ContactProvider.DeepLoad, new object[] { transactionManager, entity.ContactIdContactCollection_From_ContactCreditCard, 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.Culture"/> 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.Culture 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.Culture 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 GetByCultureId methods when available #region ProductModelProductDescriptionCultureCollection //Relationship Type One : Many if (CanDeepLoad(entity, "List<ProductModelProductDescriptionCulture>|ProductModelProductDescriptionCultureCollection", deepLoadType, innerList)) { #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'ProductModelProductDescriptionCultureCollection' loaded. key " + entity.EntityTrackingKey); #endif entity.ProductModelProductDescriptionCultureCollection = DataRepository.ProductModelProductDescriptionCultureProvider.GetByCultureId(transactionManager, entity.CultureId); if (deep && entity.ProductModelProductDescriptionCultureCollection.Count > 0) { deepHandles.Add("ProductModelProductDescriptionCultureCollection", new KeyValuePair <Delegate, object>((DeepLoadHandle <ProductModelProductDescriptionCulture>)DataRepository.ProductModelProductDescriptionCultureProvider.DeepLoad, new object[] { transactionManager, entity.ProductModelProductDescriptionCultureCollection, deep, deepLoadType, childTypes, innerList } )); } } #endregion #region ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture // RelationshipType.ManyToMany if (CanDeepLoad(entity, "List<ProductModel>|ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture", deepLoadType, innerList)) { entity.ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture = DataRepository.ProductModelProvider.GetByCultureIdFromProductModelProductDescriptionCulture(transactionManager, entity.CultureId); #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture' loaded. key " + entity.EntityTrackingKey); #endif if (deep && entity.ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture != null) { deepHandles.Add("ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture", new KeyValuePair <Delegate, object>((DeepLoadHandle <ProductModel>)DataRepository.ProductModelProvider.DeepLoad, new object[] { transactionManager, entity.ProductModelIdProductModelCollection_From_ProductModelProductDescriptionCulture, deep, deepLoadType, childTypes, innerList } )); } } #endregion #region ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture // RelationshipType.ManyToMany if (CanDeepLoad(entity, "List<ProductDescription>|ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture", deepLoadType, innerList)) { entity.ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture = DataRepository.ProductDescriptionProvider.GetByCultureIdFromProductModelProductDescriptionCulture(transactionManager, entity.CultureId); #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture' loaded. key " + entity.EntityTrackingKey); #endif if (deep && entity.ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture != null) { deepHandles.Add("ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture", new KeyValuePair <Delegate, object>((DeepLoadHandle <ProductDescription>)DataRepository.ProductDescriptionProvider.DeepLoad, new object[] { transactionManager, entity.ProductDescriptionIdProductDescriptionCollection_From_ProductModelProductDescriptionCulture, 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; }
/// <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.Profile"/> 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.Profile 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.Profile 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 GetByUniqueId methods when available #region CartCollection //Relationship Type One : Many if (CanDeepLoad(entity, "List<Cart>|CartCollection", deepLoadType, innerList)) { #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'CartCollection' loaded. key " + entity.EntityTrackingKey); #endif entity.CartCollection = DataRepository.CartProvider.GetByUniqueId(transactionManager, entity.UniqueId); if (deep && entity.CartCollection.Count > 0) { deepHandles.Add("CartCollection", new KeyValuePair <Delegate, object>((DeepLoadHandle <Cart>)DataRepository.CartProvider.DeepLoad, new object[] { transactionManager, entity.CartCollection, deep, deepLoadType, childTypes, innerList } )); } } #endregion #region AccountCollection //Relationship Type One : Many if (CanDeepLoad(entity, "List<Account>|AccountCollection", deepLoadType, innerList)) { #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'AccountCollection' loaded. key " + entity.EntityTrackingKey); #endif entity.AccountCollection = DataRepository.AccountProvider.GetByUniqueId(transactionManager, entity.UniqueId); if (deep && entity.AccountCollection.Count > 0) { deepHandles.Add("AccountCollection", new KeyValuePair <Delegate, object>((DeepLoadHandle <Account>)DataRepository.AccountProvider.DeepLoad, new object[] { transactionManager, entity.AccountCollection, 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.UnitMeasure"/> 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.UnitMeasure 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.UnitMeasure 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 GetByUnitMeasureCode methods when available #region BillOfMaterialsCollection //Relationship Type One : Many if (CanDeepLoad(entity, "List<BillOfMaterials>|BillOfMaterialsCollection", deepLoadType, innerList)) { #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'BillOfMaterialsCollection' loaded. key " + entity.EntityTrackingKey); #endif entity.BillOfMaterialsCollection = DataRepository.BillOfMaterialsProvider.GetByUnitMeasureCode(transactionManager, entity.UnitMeasureCode); if (deep && entity.BillOfMaterialsCollection.Count > 0) { deepHandles.Add("BillOfMaterialsCollection", new KeyValuePair <Delegate, object>((DeepLoadHandle <BillOfMaterials>)DataRepository.BillOfMaterialsProvider.DeepLoad, new object[] { transactionManager, entity.BillOfMaterialsCollection, deep, deepLoadType, childTypes, innerList } )); } } #endregion #region ProductCollectionGetByWeightUnitMeasureCode //Relationship Type One : Many if (CanDeepLoad(entity, "List<Product>|ProductCollectionGetByWeightUnitMeasureCode", deepLoadType, innerList)) { #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'ProductCollectionGetByWeightUnitMeasureCode' loaded. key " + entity.EntityTrackingKey); #endif entity.ProductCollectionGetByWeightUnitMeasureCode = DataRepository.ProductProvider.GetByWeightUnitMeasureCode(transactionManager, entity.UnitMeasureCode); if (deep && entity.ProductCollectionGetByWeightUnitMeasureCode.Count > 0) { deepHandles.Add("ProductCollectionGetByWeightUnitMeasureCode", new KeyValuePair <Delegate, object>((DeepLoadHandle <Product>)DataRepository.ProductProvider.DeepLoad, new object[] { transactionManager, entity.ProductCollectionGetByWeightUnitMeasureCode, deep, deepLoadType, childTypes, innerList } )); } } #endregion #region ProductVendorCollection //Relationship Type One : Many if (CanDeepLoad(entity, "List<ProductVendor>|ProductVendorCollection", deepLoadType, innerList)) { #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'ProductVendorCollection' loaded. key " + entity.EntityTrackingKey); #endif entity.ProductVendorCollection = DataRepository.ProductVendorProvider.GetByUnitMeasureCode(transactionManager, entity.UnitMeasureCode); if (deep && entity.ProductVendorCollection.Count > 0) { deepHandles.Add("ProductVendorCollection", new KeyValuePair <Delegate, object>((DeepLoadHandle <ProductVendor>)DataRepository.ProductVendorProvider.DeepLoad, new object[] { transactionManager, entity.ProductVendorCollection, deep, deepLoadType, childTypes, innerList } )); } } #endregion #region ProductCollectionGetBySizeUnitMeasureCode //Relationship Type One : Many if (CanDeepLoad(entity, "List<Product>|ProductCollectionGetBySizeUnitMeasureCode", deepLoadType, innerList)) { #if NETTIERS_DEBUG System.Diagnostics.Debug.WriteLine("- property 'ProductCollectionGetBySizeUnitMeasureCode' loaded. key " + entity.EntityTrackingKey); #endif entity.ProductCollectionGetBySizeUnitMeasureCode = DataRepository.ProductProvider.GetBySizeUnitMeasureCode(transactionManager, entity.UnitMeasureCode); if (deep && entity.ProductCollectionGetBySizeUnitMeasureCode.Count > 0) { deepHandles.Add("ProductCollectionGetBySizeUnitMeasureCode", new KeyValuePair <Delegate, object>((DeepLoadHandle <Product>)DataRepository.ProductProvider.DeepLoad, new object[] { transactionManager, entity.ProductCollectionGetBySizeUnitMeasureCode, 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; }