Beispiel #1
0
 /// <summary> Retrieves the related entity of type 'KeywordEntity', using a relation of type 'n:1'</summary>
 /// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
 /// <returns>A fetched entity of type 'KeywordEntity' which is related to this entity.</returns>
 public virtual KeywordEntity GetSingleKeyword(bool forceFetch)
 {
     if ((!_alreadyFetchedKeyword || forceFetch || _alwaysFetchKeyword) && !this.IsSerializing && !this.IsDeserializing && !this.InDesignMode)
     {
         bool          performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.KeywordEntityUsingKeywordId);
         KeywordEntity newEntity          = new KeywordEntity();
         bool          fetchResult        = false;
         if (performLazyLoading)
         {
             AddToTransactionIfNecessary(newEntity);
             fetchResult = newEntity.FetchUsingPK(this.KeywordId);
         }
         if (fetchResult)
         {
             newEntity = (KeywordEntity)GetFromActiveContext(newEntity);
         }
         else
         {
             if (!_keywordReturnsNewIfNotFound)
             {
                 RemoveFromTransactionIfNecessary(newEntity);
                 newEntity = null;
             }
         }
         this.Keyword           = newEntity;
         _alreadyFetchedKeyword = fetchResult;
     }
     return(_keyword);
 }
        public void AddProductKeyword(int productId, string keyword)
        {
            ProductEntity p = new ProductEntity(productId);
            KeywordCollection keywords = new KeywordCollection();
            keywords.GetMulti(null);

            if (keywords.Any(pr => pr.Keyword == keyword))
            {
                int keywordId = keywords.Where<KeywordEntity>(f => f.Keyword == keyword).FirstOrDefault().Id;

                ProductKeywordEntity productKeyword = new ProductKeywordEntity();
                productKeyword.KeywordId = keywordId;
                productKeyword.ProductId = productId;
                productKeyword.Save();
            }
            else
            {
                KeywordEntity k = new KeywordEntity();
                k.Keyword = keyword;
                k.Save();

                ProductKeywordEntity newProductKeyword = new ProductKeywordEntity();
                newProductKeyword.KeywordId = k.Id;
                newProductKeyword.ProductId = productId;
                newProductKeyword.Save();

            }
        }
Beispiel #3
0
 /// <summary> setups the sync logic for member _keyword</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncKeyword(IEntity relatedEntity)
 {
     if (_keyword != relatedEntity)
     {
         DesetupSyncKeyword(true, true);
         _keyword = (KeywordEntity)relatedEntity;
         this.PerformSetupSyncRelatedEntity(_keyword, new PropertyChangedEventHandler(OnKeywordPropertyChanged), "Keyword", ProductSearchEngine.RelationClasses.StaticProductKeywordRelations.KeywordEntityUsingKeywordIdStatic, true, ref _alreadyFetchedKeyword, new string[] {  });
     }
 }
Beispiel #4
0
        /// <summary>Private CTor for deserialization</summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected ProductKeywordEntity(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            _keyword = (KeywordEntity)info.GetValue("_keyword", typeof(KeywordEntity));
            if (_keyword != null)
            {
                _keyword.AfterSave += new EventHandler(OnEntityAfterSave);
            }
            _keywordReturnsNewIfNotFound = info.GetBoolean("_keywordReturnsNewIfNotFound");
            _alwaysFetchKeyword          = info.GetBoolean("_alwaysFetchKeyword");
            _alreadyFetchedKeyword       = info.GetBoolean("_alreadyFetchedKeyword");

            _product = (ProductEntity)info.GetValue("_product", typeof(ProductEntity));
            if (_product != null)
            {
                _product.AfterSave += new EventHandler(OnEntityAfterSave);
            }
            _productReturnsNewIfNotFound = info.GetBoolean("_productReturnsNewIfNotFound");
            _alwaysFetchProduct          = info.GetBoolean("_alwaysFetchProduct");
            _alreadyFetchedProduct       = info.GetBoolean("_alreadyFetchedProduct");
            this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance());
            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
        /// <summary>Creates a new, empty KeywordEntity object.</summary>
        /// <returns>A new, empty KeywordEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new KeywordEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewKeyword
            // __LLBLGENPRO_USER_CODE_REGION_END
            return toReturn;
        }
Beispiel #6
0
 /// <summary> Removes the sync logic for member _keyword</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 DesetupSyncKeyword(bool signalRelatedEntity, bool resetFKFields)
 {
     this.PerformDesetupSyncRelatedEntity(_keyword, new PropertyChangedEventHandler(OnKeywordPropertyChanged), "Keyword", ProductSearchEngine.RelationClasses.StaticProductKeywordRelations.KeywordEntityUsingKeywordIdStatic, true, signalRelatedEntity, "ProductKeywords", resetFKFields, new int[] { (int)ProductKeywordFieldIndex.KeywordId });
     _keyword = null;
 }
 /// <summary> setups the sync logic for member _keyword</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncKeyword(IEntity relatedEntity)
 {
     if(_keyword!=relatedEntity)
     {
         DesetupSyncKeyword(true, true);
         _keyword = (KeywordEntity)relatedEntity;
         this.PerformSetupSyncRelatedEntity( _keyword, new PropertyChangedEventHandler( OnKeywordPropertyChanged ), "Keyword", ProductSearchEngine.RelationClasses.StaticProductKeywordRelations.KeywordEntityUsingKeywordIdStatic, true, ref _alreadyFetchedKeyword, new string[] {  } );
     }
 }
 /// <summary> Removes the sync logic for member _keyword</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 DesetupSyncKeyword(bool signalRelatedEntity, bool resetFKFields)
 {
     this.PerformDesetupSyncRelatedEntity( _keyword, new PropertyChangedEventHandler( OnKeywordPropertyChanged ), "Keyword", ProductSearchEngine.RelationClasses.StaticProductKeywordRelations.KeywordEntityUsingKeywordIdStatic, true, signalRelatedEntity, "ProductKeywords", resetFKFields, new int[] { (int)ProductKeywordFieldIndex.KeywordId } );
     _keyword = null;
 }
 /// <summary> Retrieves the related entity of type 'KeywordEntity', using a relation of type 'n:1'</summary>
 /// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
 /// <returns>A fetched entity of type 'KeywordEntity' which is related to this entity.</returns>
 public virtual KeywordEntity GetSingleKeyword(bool forceFetch)
 {
     if( ( !_alreadyFetchedKeyword || forceFetch || _alwaysFetchKeyword) && !this.IsSerializing && !this.IsDeserializing  && !this.InDesignMode)
     {
         bool performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.KeywordEntityUsingKeywordId);
         KeywordEntity newEntity = new KeywordEntity();
         bool fetchResult = false;
         if(performLazyLoading)
         {
             AddToTransactionIfNecessary(newEntity);
             fetchResult = newEntity.FetchUsingPK(this.KeywordId);
         }
         if(fetchResult)
         {
             newEntity = (KeywordEntity)GetFromActiveContext(newEntity);
         }
         else
         {
             if(!_keywordReturnsNewIfNotFound)
             {
                 RemoveFromTransactionIfNecessary(newEntity);
                 newEntity = null;
             }
         }
         this.Keyword = newEntity;
         _alreadyFetchedKeyword = fetchResult;
     }
     return _keyword;
 }
        /// <summary>Private CTor for deserialization</summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected ProductKeywordEntity(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            _keyword = (KeywordEntity)info.GetValue("_keyword", typeof(KeywordEntity));
            if(_keyword!=null)
            {
                _keyword.AfterSave+=new EventHandler(OnEntityAfterSave);
            }
            _keywordReturnsNewIfNotFound = info.GetBoolean("_keywordReturnsNewIfNotFound");
            _alwaysFetchKeyword = info.GetBoolean("_alwaysFetchKeyword");
            _alreadyFetchedKeyword = info.GetBoolean("_alreadyFetchedKeyword");

            _product = (ProductEntity)info.GetValue("_product", typeof(ProductEntity));
            if(_product!=null)
            {
                _product.AfterSave+=new EventHandler(OnEntityAfterSave);
            }
            _productReturnsNewIfNotFound = info.GetBoolean("_productReturnsNewIfNotFound");
            _alwaysFetchProduct = info.GetBoolean("_alwaysFetchProduct");
            _alreadyFetchedProduct = info.GetBoolean("_alreadyFetchedProduct");
            this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance());
            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }