/// <summary> setups the sync logic for member _productCategory</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncProductCategory(IEntityCore relatedEntity)
 {
     if (_productCategory != relatedEntity)
     {
         DesetupSyncProductCategory(true, true);
         _productCategory = (ProductCategoryEntity)relatedEntity;
         this.PerformSetupSyncRelatedEntity(_productCategory, new PropertyChangedEventHandler(OnProductCategoryPropertyChanged), "ProductCategory", AdventureWorks.Dal.Adapter.v41.RelationClasses.StaticProductSubcategoryRelations.ProductCategoryEntityUsingProductCategoryIdStatic, true, new string[] {  });
     }
 }
 protected ProductSubcategoryEntity(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     if (SerializationHelper.Optimization != SerializationOptimization.Fast)
     {
         _products        = (EntityCollection <ProductEntity>)info.GetValue("_products", typeof(EntityCollection <ProductEntity>));
         _productCategory = (ProductCategoryEntity)info.GetValue("_productCategory", typeof(ProductCategoryEntity));
         if (_productCategory != null)
         {
             _productCategory.AfterSave += new EventHandler(OnEntityAfterSave);
         }
         this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance());
     }
     // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
     // __LLBLGENPRO_USER_CODE_REGION_END
 }
		/// <summary> setups the sync logic for member _productCategory</summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		private void SetupSyncProductCategory(IEntityCore relatedEntity)
		{
			if(_productCategory!=relatedEntity)
			{
				DesetupSyncProductCategory(true, true);
				_productCategory = (ProductCategoryEntity)relatedEntity;
				this.PerformSetupSyncRelatedEntity( _productCategory, new PropertyChangedEventHandler( OnProductCategoryPropertyChanged ), "ProductCategory", AdventureWorks.Dal.Adapter.v41.RelationClasses.StaticProductSubcategoryRelations.ProductCategoryEntityUsingProductCategoryIdStatic, true, new string[] {  } );
			}
		}
		/// <summary> Removes the sync logic for member _productCategory</summary>
		/// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
		/// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param>
		private void DesetupSyncProductCategory(bool signalRelatedEntity, bool resetFKFields)
		{
			this.PerformDesetupSyncRelatedEntity( _productCategory, new PropertyChangedEventHandler( OnProductCategoryPropertyChanged ), "ProductCategory", AdventureWorks.Dal.Adapter.v41.RelationClasses.StaticProductSubcategoryRelations.ProductCategoryEntityUsingProductCategoryIdStatic, true, signalRelatedEntity, "ProductSubcategories", resetFKFields, new int[] { (int)ProductSubcategoryFieldIndex.ProductCategoryId } );
			_productCategory = null;
		}
		protected ProductSubcategoryEntity(SerializationInfo info, StreamingContext context) : base(info, context)
		{
			if(SerializationHelper.Optimization != SerializationOptimization.Fast) 
			{
				_products = (EntityCollection<ProductEntity>)info.GetValue("_products", typeof(EntityCollection<ProductEntity>));
				_productCategory = (ProductCategoryEntity)info.GetValue("_productCategory", typeof(ProductCategoryEntity));
				if(_productCategory!=null)
				{
					_productCategory.AfterSave+=new EventHandler(OnEntityAfterSave);
				}
				this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance());
			}
			// __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
			// __LLBLGENPRO_USER_CODE_REGION_END
			
		}
 /// <summary> Removes the sync logic for member _productCategory</summary>
 /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
 /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param>
 private void DesetupSyncProductCategory(bool signalRelatedEntity, bool resetFKFields)
 {
     this.PerformDesetupSyncRelatedEntity(_productCategory, new PropertyChangedEventHandler(OnProductCategoryPropertyChanged), "ProductCategory", AdventureWorks.Dal.Adapter.v41.RelationClasses.StaticProductSubcategoryRelations.ProductCategoryEntityUsingProductCategoryIdStatic, true, signalRelatedEntity, "ProductSubcategories", resetFKFields, new int[] { (int)ProductSubcategoryFieldIndex.ProductCategoryId });
     _productCategory = null;
 }