public void ChangeStoreStatus(int id,bool status)
        {
            MembershipEntity membership = new MembershipEntity(id);
            membership.Status = status;

            membership.Save();
        }
 /// <summary> Retrieves the related entity of type 'MembershipEntity', 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 'MembershipEntity' which is related to this entity.</returns>
 public virtual MembershipEntity GetSingleMembership(bool forceFetch)
 {
     if ((!_alreadyFetchedMembership || forceFetch || _alwaysFetchMembership) && !this.IsSerializing && !this.IsDeserializing && !this.InDesignMode)
     {
         bool             performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.MembershipEntityUsingMembershipId);
         MembershipEntity newEntity          = new MembershipEntity();
         bool             fetchResult        = false;
         if (performLazyLoading)
         {
             AddToTransactionIfNecessary(newEntity);
             fetchResult = newEntity.FetchUsingPK(this.MembershipId.GetValueOrDefault());
         }
         if (fetchResult)
         {
             newEntity = (MembershipEntity)GetFromActiveContext(newEntity);
         }
         else
         {
             if (!_membershipReturnsNewIfNotFound)
             {
                 RemoveFromTransactionIfNecessary(newEntity);
                 newEntity = null;
             }
         }
         this.Membership           = newEntity;
         _alreadyFetchedMembership = fetchResult;
     }
     return(_membership);
 }
 /// <summary> setups the sync logic for member _membership</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncMembership(IEntity relatedEntity)
 {
     if (_membership != relatedEntity)
     {
         DesetupSyncMembership(true, true);
         _membership = (MembershipEntity)relatedEntity;
         this.PerformSetupSyncRelatedEntity(_membership, new PropertyChangedEventHandler(OnMembershipPropertyChanged), "Membership", ProductSearchEngine.RelationClasses.StaticStoreRelations.MembershipEntityUsingMembershipIdStatic, true, ref _alreadyFetchedMembership, new string[] {  });
     }
 }
 /// <summary>Private CTor for deserialization</summary>
 /// <param name="info"></param>
 /// <param name="context"></param>
 protected StoreEntity(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     _products               = (ProductSearchEngine.CollectionClasses.ProductCollection)info.GetValue("_products", typeof(ProductSearchEngine.CollectionClasses.ProductCollection));
     _alwaysFetchProducts    = info.GetBoolean("_alwaysFetchProducts");
     _alreadyFetchedProducts = info.GetBoolean("_alreadyFetchedProducts");
     _membership             = (MembershipEntity)info.GetValue("_membership", typeof(MembershipEntity));
     if (_membership != null)
     {
         _membership.AfterSave += new EventHandler(OnEntityAfterSave);
     }
     _membershipReturnsNewIfNotFound = info.GetBoolean("_membershipReturnsNewIfNotFound");
     _alwaysFetchMembership          = info.GetBoolean("_alwaysFetchMembership");
     _alreadyFetchedMembership       = info.GetBoolean("_alreadyFetchedMembership");
     this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance());
     // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
     // __LLBLGENPRO_USER_CODE_REGION_END
 }
        /// <summary>Creates a new, empty MembershipEntity object.</summary>
        /// <returns>A new, empty MembershipEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new MembershipEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewMembership
            // __LLBLGENPRO_USER_CODE_REGION_END
            return toReturn;
        }
 public MembershipEntity UpdateMember(MembershipEntity member)
 {
     member.Save();
     return member;
 }
        //public ProductCollection SortProductsByRate(ProductCollection productList, bool isAscending)
        //{
        //}
        public ProductCollection GetLast5AddedProducts(object m)
        {
            MembershipEntity member = new MembershipEntity(3);
            ProductCollection products = new ProductCollection();
            RelationCollection relations = new RelationCollection();
            relations.Add(ProductEntity.Relations.StoreEntityUsingStoreId);
            relations.Add(StoreEntity.Relations.MembershipEntityUsingMembershipId);

            IPrefetchPath prefatchPath = new PrefetchPath((int)EntityType.ProductEntity);
            prefatchPath.Add(ProductEntity.PrefetchPathStore).SubPath.Add(StoreEntity.PrefetchPathMembership);

            PredicateExpression filter = new PredicateExpression();

            filter.Add(MembershipFields.Id == member.Id);

            SortExpression sorter = new SortExpression();

            sorter.Add(ProductFields.AddedDate | SortOperator.Descending);
            products.GetMulti(filter, 5, sorter, relations, prefatchPath);

            return products;
        }
 /// <summary> Removes the sync logic for member _membership</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 DesetupSyncMembership(bool signalRelatedEntity, bool resetFKFields)
 {
     this.PerformDesetupSyncRelatedEntity(_membership, new PropertyChangedEventHandler(OnMembershipPropertyChanged), "Membership", ProductSearchEngine.RelationClasses.StaticStoreRelations.MembershipEntityUsingMembershipIdStatic, true, signalRelatedEntity, "Stores", resetFKFields, new int[] { (int)StoreFieldIndex.MembershipId });
     _membership = null;
 }
 /// <summary> setups the sync logic for member _membership</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncMembership(IEntity relatedEntity)
 {
     if(_membership!=relatedEntity)
     {
         DesetupSyncMembership(true, true);
         _membership = (MembershipEntity)relatedEntity;
         this.PerformSetupSyncRelatedEntity( _membership, new PropertyChangedEventHandler( OnMembershipPropertyChanged ), "Membership", ProductSearchEngine.RelationClasses.StaticStoreRelations.MembershipEntityUsingMembershipIdStatic, true, ref _alreadyFetchedMembership, new string[] {  } );
     }
 }
 /// <summary> Removes the sync logic for member _membership</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 DesetupSyncMembership(bool signalRelatedEntity, bool resetFKFields)
 {
     this.PerformDesetupSyncRelatedEntity( _membership, new PropertyChangedEventHandler( OnMembershipPropertyChanged ), "Membership", ProductSearchEngine.RelationClasses.StaticStoreRelations.MembershipEntityUsingMembershipIdStatic, true, signalRelatedEntity, "Stores", resetFKFields, new int[] { (int)StoreFieldIndex.MembershipId } );
     _membership = null;
 }
 /// <summary> Retrieves the related entity of type 'MembershipEntity', 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 'MembershipEntity' which is related to this entity.</returns>
 public virtual MembershipEntity GetSingleMembership(bool forceFetch)
 {
     if( ( !_alreadyFetchedMembership || forceFetch || _alwaysFetchMembership) && !this.IsSerializing && !this.IsDeserializing  && !this.InDesignMode)
     {
         bool performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.MembershipEntityUsingMembershipId);
         MembershipEntity newEntity = new MembershipEntity();
         bool fetchResult = false;
         if(performLazyLoading)
         {
             AddToTransactionIfNecessary(newEntity);
             fetchResult = newEntity.FetchUsingPK(this.MembershipId.GetValueOrDefault());
         }
         if(fetchResult)
         {
             newEntity = (MembershipEntity)GetFromActiveContext(newEntity);
         }
         else
         {
             if(!_membershipReturnsNewIfNotFound)
             {
                 RemoveFromTransactionIfNecessary(newEntity);
                 newEntity = null;
             }
         }
         this.Membership = newEntity;
         _alreadyFetchedMembership = fetchResult;
     }
     return _membership;
 }
 /// <summary>Private CTor for deserialization</summary>
 /// <param name="info"></param>
 /// <param name="context"></param>
 protected StoreEntity(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     _products = (ProductSearchEngine.CollectionClasses.ProductCollection)info.GetValue("_products", typeof(ProductSearchEngine.CollectionClasses.ProductCollection));
     _alwaysFetchProducts = info.GetBoolean("_alwaysFetchProducts");
     _alreadyFetchedProducts = info.GetBoolean("_alreadyFetchedProducts");
     _membership = (MembershipEntity)info.GetValue("_membership", typeof(MembershipEntity));
     if(_membership!=null)
     {
         _membership.AfterSave+=new EventHandler(OnEntityAfterSave);
     }
     _membershipReturnsNewIfNotFound = info.GetBoolean("_membershipReturnsNewIfNotFound");
     _alwaysFetchMembership = info.GetBoolean("_alwaysFetchMembership");
     _alreadyFetchedMembership = info.GetBoolean("_alreadyFetchedMembership");
     this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance());
     // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
     // __LLBLGENPRO_USER_CODE_REGION_END
 }