/// <summary> Removes the sync logic for member _document</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 DesetupSyncDocument(bool signalRelatedEntity, bool resetFKFields)
 {
     this.PerformDesetupSyncRelatedEntity(_document, new PropertyChangedEventHandler(OnDocumentPropertyChanged), "Document", AdventureWorks.Dal.Adapter.v42.RelationClasses.StaticProductDocumentRelations.DocumentEntityUsingDocumentNodeStatic, true, signalRelatedEntity, "ProductDocuments", resetFKFields, new int[] { (int)ProductDocumentFieldIndex.DocumentNode });
     _document = null;
 }
		/// <summary> Removes the sync logic for member _document</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 DesetupSyncDocument(bool signalRelatedEntity, bool resetFKFields)
		{
			this.PerformDesetupSyncRelatedEntity( _document, new PropertyChangedEventHandler( OnDocumentPropertyChanged ), "Document", AdventureWorks.Dal.Adapter.v42.RelationClasses.StaticProductDocumentRelations.DocumentEntityUsingDocumentNodeStatic, true, signalRelatedEntity, "ProductDocuments", resetFKFields, new int[] { (int)ProductDocumentFieldIndex.DocumentNode } );
			_document = null;
		}
		/// <summary> setups the sync logic for member _document</summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		private void SetupSyncDocument(IEntityCore relatedEntity)
		{
			if(_document!=relatedEntity)
			{
				DesetupSyncDocument(true, true);
				_document = (DocumentEntity)relatedEntity;
				this.PerformSetupSyncRelatedEntity( _document, new PropertyChangedEventHandler( OnDocumentPropertyChanged ), "Document", AdventureWorks.Dal.Adapter.v42.RelationClasses.StaticProductDocumentRelations.DocumentEntityUsingDocumentNodeStatic, true, new string[] {  } );
			}
		}
		protected ProductDocumentEntity(SerializationInfo info, StreamingContext context) : base(info, context)
		{
			if(SerializationHelper.Optimization != SerializationOptimization.Fast) 
			{
				_document = (DocumentEntity)info.GetValue("_document", typeof(DocumentEntity));
				if(_document!=null)
				{
					_document.AfterSave+=new EventHandler(OnEntityAfterSave);
				}
				_product = (ProductEntity)info.GetValue("_product", typeof(ProductEntity));
				if(_product!=null)
				{
					_product.AfterSave+=new EventHandler(OnEntityAfterSave);
				}
				this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance());
			}
			// __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
			// __LLBLGENPRO_USER_CODE_REGION_END
		}