/// <summary>Creates a new, empty BrandEntity object.</summary>
        /// <returns>A new, empty BrandEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new BrandEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewBrand
            // __LLBLGENPRO_USER_CODE_REGION_END
            return toReturn;
        }
 public void UpdateBrand(int brandId, string name)
 {
     BrandEntity brand = new BrandEntity(brandId);
     brand.Name = name;
     brand.Save();
 }
 public bool RemoveBrand(int brandId)
 {
     BrandEntity brand = new BrandEntity(brandId);
     return brand.Delete();
 }
 public void AddBrand(string name)
 {
     BrandEntity brand = new BrandEntity();
     brand.Name = name;
     brand.Save();
 }
 /// <summary> Retrieves the related entity of type 'BrandEntity', 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 'BrandEntity' which is related to this entity.</returns>
 public virtual BrandEntity GetSingleBrand(bool forceFetch)
 {
     if( ( !_alreadyFetchedBrand || forceFetch || _alwaysFetchBrand) && !this.IsSerializing && !this.IsDeserializing  && !this.InDesignMode)
     {
         bool performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.BrandEntityUsingBrandId);
         BrandEntity newEntity = new BrandEntity();
         bool fetchResult = false;
         if(performLazyLoading)
         {
             AddToTransactionIfNecessary(newEntity);
             fetchResult = newEntity.FetchUsingPK(this.BrandId.GetValueOrDefault());
         }
         if(fetchResult)
         {
             newEntity = (BrandEntity)GetFromActiveContext(newEntity);
         }
         else
         {
             if(!_brandReturnsNewIfNotFound)
             {
                 RemoveFromTransactionIfNecessary(newEntity);
                 newEntity = null;
             }
         }
         this.Brand = newEntity;
         _alreadyFetchedBrand = fetchResult;
     }
     return _brand;
 }
 /// <summary> setups the sync logic for member _brand</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncBrand(IEntity relatedEntity)
 {
     if(_brand!=relatedEntity)
     {
         DesetupSyncBrand(true, true);
         _brand = (BrandEntity)relatedEntity;
         this.PerformSetupSyncRelatedEntity( _brand, new PropertyChangedEventHandler( OnBrandPropertyChanged ), "Brand", ProductSearchEngine.RelationClasses.StaticProductRelations.BrandEntityUsingBrandIdStatic, true, ref _alreadyFetchedBrand, new string[] {  } );
     }
 }
 /// <summary> Removes the sync logic for member _brand</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 DesetupSyncBrand(bool signalRelatedEntity, bool resetFKFields)
 {
     this.PerformDesetupSyncRelatedEntity( _brand, new PropertyChangedEventHandler( OnBrandPropertyChanged ), "Brand", ProductSearchEngine.RelationClasses.StaticProductRelations.BrandEntityUsingBrandIdStatic, true, signalRelatedEntity, "Products", resetFKFields, new int[] { (int)ProductFieldIndex.BrandId } );
     _brand = null;
 }
        /// <summary>Private CTor for deserialization</summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected ProductEntity(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            _comments = (ProductSearchEngine.CollectionClasses.CommentCollection)info.GetValue("_comments", typeof(ProductSearchEngine.CollectionClasses.CommentCollection));
            _alwaysFetchComments = info.GetBoolean("_alwaysFetchComments");
            _alreadyFetchedComments = info.GetBoolean("_alreadyFetchedComments");

            _productKeywords = (ProductSearchEngine.CollectionClasses.ProductKeywordCollection)info.GetValue("_productKeywords", typeof(ProductSearchEngine.CollectionClasses.ProductKeywordCollection));
            _alwaysFetchProductKeywords = info.GetBoolean("_alwaysFetchProductKeywords");
            _alreadyFetchedProductKeywords = info.GetBoolean("_alreadyFetchedProductKeywords");

            _productPhotos = (ProductSearchEngine.CollectionClasses.ProductPhotoCollection)info.GetValue("_productPhotos", typeof(ProductSearchEngine.CollectionClasses.ProductPhotoCollection));
            _alwaysFetchProductPhotos = info.GetBoolean("_alwaysFetchProductPhotos");
            _alreadyFetchedProductPhotos = info.GetBoolean("_alreadyFetchedProductPhotos");

            _productSpecifications = (ProductSearchEngine.CollectionClasses.ProductSpecificationCollection)info.GetValue("_productSpecifications", typeof(ProductSearchEngine.CollectionClasses.ProductSpecificationCollection));
            _alwaysFetchProductSpecifications = info.GetBoolean("_alwaysFetchProductSpecifications");
            _alreadyFetchedProductSpecifications = info.GetBoolean("_alreadyFetchedProductSpecifications");
            _brand = (BrandEntity)info.GetValue("_brand", typeof(BrandEntity));
            if(_brand!=null)
            {
                _brand.AfterSave+=new EventHandler(OnEntityAfterSave);
            }
            _brandReturnsNewIfNotFound = info.GetBoolean("_brandReturnsNewIfNotFound");
            _alwaysFetchBrand = info.GetBoolean("_alwaysFetchBrand");
            _alreadyFetchedBrand = info.GetBoolean("_alreadyFetchedBrand");

            _category = (CategoryEntity)info.GetValue("_category", typeof(CategoryEntity));
            if(_category!=null)
            {
                _category.AfterSave+=new EventHandler(OnEntityAfterSave);
            }
            _categoryReturnsNewIfNotFound = info.GetBoolean("_categoryReturnsNewIfNotFound");
            _alwaysFetchCategory = info.GetBoolean("_alwaysFetchCategory");
            _alreadyFetchedCategory = info.GetBoolean("_alreadyFetchedCategory");

            _store = (StoreEntity)info.GetValue("_store", typeof(StoreEntity));
            if(_store!=null)
            {
                _store.AfterSave+=new EventHandler(OnEntityAfterSave);
            }
            _storeReturnsNewIfNotFound = info.GetBoolean("_storeReturnsNewIfNotFound");
            _alwaysFetchStore = info.GetBoolean("_alwaysFetchStore");
            _alreadyFetchedStore = info.GetBoolean("_alreadyFetchedStore");
            this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance());
            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }