コード例 #1
0
 /// <summary> Retrieves the related entity of type 'TerritoryEntity', 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 'TerritoryEntity' which is related to this entity.</returns>
 public virtual TerritoryEntity GetSingleTerritory(bool forceFetch)
 {
     if ((!_alreadyFetchedTerritory || forceFetch || _alwaysFetchTerritory) && !this.IsSerializing && !this.IsDeserializing && !this.InDesignMode)
     {
         bool            performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.TerritoryEntityUsingTerritoryId);
         TerritoryEntity newEntity          = new TerritoryEntity();
         bool            fetchResult        = false;
         if (performLazyLoading)
         {
             AddToTransactionIfNecessary(newEntity);
             fetchResult = newEntity.FetchUsingPK(this.TerritoryId);
         }
         if (fetchResult)
         {
             newEntity = (TerritoryEntity)GetFromActiveContext(newEntity);
         }
         else
         {
             if (!_territoryReturnsNewIfNotFound)
             {
                 RemoveFromTransactionIfNecessary(newEntity);
                 newEntity = null;
             }
         }
         this.Territory           = newEntity;
         _alreadyFetchedTerritory = fetchResult;
     }
     return(_territory);
 }
コード例 #2
0
 /// <summary> setups the sync logic for member _territory</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncTerritory(IEntityCore relatedEntity)
 {
     if (_territory != relatedEntity)
     {
         DesetupSyncTerritory(true, true);
         _territory = (TerritoryEntity)relatedEntity;
         this.PerformSetupSyncRelatedEntity(_territory, new PropertyChangedEventHandler(OnTerritoryPropertyChanged), "Territory", SD.LLBLGen.Pro.Examples.RelationClasses.StaticEmployeeTerritoryRelations.TerritoryEntityUsingTerritoryIdStatic, true, ref _alreadyFetchedTerritory, new string[] {  });
     }
 }
コード例 #3
0
 protected EmployeeTerritoryEntity(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     if (SerializationHelper.Optimization != SerializationOptimization.Fast)
     {
         _employee = (EmployeeEntity)info.GetValue("_employee", typeof(EmployeeEntity));
         if (_employee != null)
         {
             _employee.AfterSave += new EventHandler(OnEntityAfterSave);
         }
         _territory = (TerritoryEntity)info.GetValue("_territory", typeof(TerritoryEntity));
         if (_territory != null)
         {
             _territory.AfterSave += new EventHandler(OnEntityAfterSave);
         }
         this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance());
     }
     // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
     // __LLBLGENPRO_USER_CODE_REGION_END
 }
コード例 #4
0
        /// <summary>Private CTor for deserialization</summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected EmployeeTerritoryEntity(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            _employee = (EmployeeEntity)info.GetValue("_employee", typeof(EmployeeEntity));
            if (_employee != null)
            {
                _employee.AfterSave += new EventHandler(OnEntityAfterSave);
            }
            _employeeReturnsNewIfNotFound = info.GetBoolean("_employeeReturnsNewIfNotFound");
            _alwaysFetchEmployee          = info.GetBoolean("_alwaysFetchEmployee");
            _alreadyFetchedEmployee       = info.GetBoolean("_alreadyFetchedEmployee");

            _territory = (TerritoryEntity)info.GetValue("_territory", typeof(TerritoryEntity));
            if (_territory != null)
            {
                _territory.AfterSave += new EventHandler(OnEntityAfterSave);
            }
            _territoryReturnsNewIfNotFound = info.GetBoolean("_territoryReturnsNewIfNotFound");
            _alwaysFetchTerritory          = info.GetBoolean("_alwaysFetchTerritory");
            _alreadyFetchedTerritory       = info.GetBoolean("_alreadyFetchedTerritory");
            this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance());
            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
コード例 #5
0
 /// <summary> Removes the sync logic for member _territory</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 DesetupSyncTerritory(bool signalRelatedEntity, bool resetFKFields)
 {
     this.PerformDesetupSyncRelatedEntity(_territory, new PropertyChangedEventHandler(OnTerritoryPropertyChanged), "Territory", SD.LLBLGen.Pro.Examples.RelationClasses.StaticEmployeeTerritoryRelations.TerritoryEntityUsingTerritoryIdStatic, true, signalRelatedEntity, "EmployeeTerritories", resetFKFields, new int[] { (int)EmployeeTerritoryFieldIndex.TerritoryId });
     _territory = null;
 }