/// <summary> Retrieves the related entity of type 'LocationEntity', 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 'LocationEntity' which is related to this entity.</returns> public virtual LocationEntity GetSingleLocation(bool forceFetch) { if ((!_alreadyFetchedLocation || forceFetch || _alwaysFetchLocation) && !this.IsSerializing && !this.IsDeserializing && !this.InDesignMode) { bool performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.LocationEntityUsingLocationId); LocationEntity newEntity = new LocationEntity(); bool fetchResult = false; if (performLazyLoading) { AddToTransactionIfNecessary(newEntity); fetchResult = newEntity.FetchUsingPK(this.LocationId); } if (fetchResult) { newEntity = (LocationEntity)GetFromActiveContext(newEntity); } else { if (!_locationReturnsNewIfNotFound) { RemoveFromTransactionIfNecessary(newEntity); newEntity = null; } } this.Location = newEntity; _alreadyFetchedLocation = fetchResult; } return(_location); }