/// <summary> Retrieves the related entity of type 'ProductEntity', 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 'ProductEntity' which is related to this entity.</returns> public virtual ProductEntity GetSingleProduct(bool forceFetch) { if ((!_alreadyFetchedProduct || forceFetch || _alwaysFetchProduct) && !this.IsSerializing && !this.IsDeserializing && !this.InDesignMode) { bool performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.ProductEntityUsingProductId); ProductEntity newEntity = new ProductEntity(); bool fetchResult = false; if (performLazyLoading) { AddToTransactionIfNecessary(newEntity); fetchResult = newEntity.FetchUsingPK(this.ProductId); } if (fetchResult) { newEntity = (ProductEntity)GetFromActiveContext(newEntity); } else { if (!_productReturnsNewIfNotFound) { RemoveFromTransactionIfNecessary(newEntity); newEntity = null; } } this.Product = newEntity; _alreadyFetchedProduct = fetchResult; } return(_product); }