/// <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); }
/// <summary> setups the sync logic for member _region</summary> /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param> private void SetupSyncRegion(IEntityCore relatedEntity) { if (_region != relatedEntity) { DesetupSyncRegion(true, true); _region = (RegionEntity)relatedEntity; this.PerformSetupSyncRelatedEntity(_region, new PropertyChangedEventHandler(OnRegionPropertyChanged), "Region", Northwind.DAL.RelationClasses.StaticTerritoryRelations.RegionEntityUsingRegionIdStatic, true, new string[] { }); } }
protected TerritoryEntity(SerializationInfo info, StreamingContext context) : base(info, context) { if (SerializationHelper.Optimization != SerializationOptimization.Fast) { _employeeTerritories = (EntityCollection <EmployeeTerritoryEntity>)info.GetValue("_employeeTerritories", typeof(EntityCollection <EmployeeTerritoryEntity>)); _region = (RegionEntity)info.GetValue("_region", typeof(RegionEntity)); if (_region != null) { _region.AfterSave += new EventHandler(OnEntityAfterSave); } this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance()); } // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor // __LLBLGENPRO_USER_CODE_REGION_END }
/// <summary>Private CTor for deserialization</summary> /// <param name="info"></param> /// <param name="context"></param> protected TerritoryEntity(SerializationInfo info, StreamingContext context) : base(info, context) { _employeeTerritories = (Northwind.DAL.CollectionClasses.EmployeeTerritoryCollection)info.GetValue("_employeeTerritories", typeof(Northwind.DAL.CollectionClasses.EmployeeTerritoryCollection)); _alwaysFetchEmployeeTerritories = info.GetBoolean("_alwaysFetchEmployeeTerritories"); _alreadyFetchedEmployeeTerritories = info.GetBoolean("_alreadyFetchedEmployeeTerritories"); _region = (RegionEntity)info.GetValue("_region", typeof(RegionEntity)); if (_region != null) { _region.AfterSave += new EventHandler(OnEntityAfterSave); } _regionReturnsNewIfNotFound = info.GetBoolean("_regionReturnsNewIfNotFound"); _alwaysFetchRegion = info.GetBoolean("_alwaysFetchRegion"); _alreadyFetchedRegion = info.GetBoolean("_alreadyFetchedRegion"); this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance()); // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor // __LLBLGENPRO_USER_CODE_REGION_END }
/// <summary> Removes the sync logic for member _region</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 DesetupSyncRegion(bool signalRelatedEntity, bool resetFKFields) { this.PerformDesetupSyncRelatedEntity(_region, new PropertyChangedEventHandler(OnRegionPropertyChanged), "Region", Northwind.DAL.RelationClasses.StaticTerritoryRelations.RegionEntityUsingRegionIdStatic, true, signalRelatedEntity, "Territories", resetFKFields, new int[] { (int)TerritoryFieldIndex.RegionId }); _region = null; }