Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
 /// <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.SSDAL.RelationClasses.StaticTerritoryRelations.RegionEntityUsingRegionIdStatic, true, ref _alreadyFetchedRegion, new string[] {  });
     }
 }
Ejemplo n.º 3
0
 /// <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.SSDAL.CollectionClasses.EmployeeTerritoryCollection)info.GetValue("_employeeTerritories", typeof(Northwind.SSDAL.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
 }
Ejemplo n.º 4
0
 /// <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.SSDAL.RelationClasses.StaticTerritoryRelations.RegionEntityUsingRegionIdStatic, true, signalRelatedEntity, "Territories", resetFKFields, new int[] { (int)TerritoryFieldIndex.RegionId });
     _region = null;
 }