Exemple #1
0
 /// <summary> Retrieves the related entity of type 'RegionEntity', 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 'RegionEntity' which is related to this entity.</returns>
 public virtual RegionEntity GetSingleRegion(bool forceFetch)
 {
     if ((!_alreadyFetchedRegion || forceFetch || _alwaysFetchRegion) && !this.IsSerializing && !this.IsDeserializing && !this.InDesignMode)
     {
         bool         performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.RegionEntityUsingRegionId);
         RegionEntity newEntity          = new RegionEntity();
         bool         fetchResult        = false;
         if (performLazyLoading)
         {
             AddToTransactionIfNecessary(newEntity);
             fetchResult = newEntity.FetchUsingPK(this.RegionId);
         }
         if (fetchResult)
         {
             newEntity = (RegionEntity)GetFromActiveContext(newEntity);
         }
         else
         {
             if (!_regionReturnsNewIfNotFound)
             {
                 RemoveFromTransactionIfNecessary(newEntity);
                 newEntity = null;
             }
         }
         this.Region           = newEntity;
         _alreadyFetchedRegion = fetchResult;
     }
     return(_region);
 }