Example #1
0
 /// <summary> Retrieves the related entity of type 'RateEntity', 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 'RateEntity' which is related to this entity.</returns>
 public virtual RateEntity GetSingleRate(bool forceFetch)
 {
     if ((!_alreadyFetchedRate || forceFetch || _alwaysFetchRate) && !this.IsSerializing && !this.IsDeserializing && !this.InDesignMode)
     {
         bool       performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.RateEntityUsingRateId);
         RateEntity newEntity          = new RateEntity();
         bool       fetchResult        = false;
         if (performLazyLoading)
         {
             AddToTransactionIfNecessary(newEntity);
             fetchResult = newEntity.FetchUsingPK(this.RateId.GetValueOrDefault());
         }
         if (fetchResult)
         {
             newEntity = (RateEntity)GetFromActiveContext(newEntity);
         }
         else
         {
             if (!_rateReturnsNewIfNotFound)
             {
                 RemoveFromTransactionIfNecessary(newEntity);
                 newEntity = null;
             }
         }
         this.Rate           = newEntity;
         _alreadyFetchedRate = fetchResult;
     }
     return(_rate);
 }
 /// <summary> Retrieves the related entity of type 'RateEntity', 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 'RateEntity' which is related to this entity.</returns>
 public virtual RateEntity GetSingleRate(bool forceFetch)
 {
     if( ( !_alreadyFetchedRate || forceFetch || _alwaysFetchRate) && !this.IsSerializing && !this.IsDeserializing  && !this.InDesignMode)
     {
         bool performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.RateEntityUsingRateId);
         RateEntity newEntity = new RateEntity();
         bool fetchResult = false;
         if(performLazyLoading)
         {
             AddToTransactionIfNecessary(newEntity);
             fetchResult = newEntity.FetchUsingPK(this.RateId.GetValueOrDefault());
         }
         if(fetchResult)
         {
             newEntity = (RateEntity)GetFromActiveContext(newEntity);
         }
         else
         {
             if(!_rateReturnsNewIfNotFound)
             {
                 RemoveFromTransactionIfNecessary(newEntity);
                 newEntity = null;
             }
         }
         this.Rate = newEntity;
         _alreadyFetchedRate = fetchResult;
     }
     return _rate;
 }