コード例 #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 GetSingleTerritories(bool forceFetch)
 {
     if ((!_alreadyFetchedTerritories || forceFetch || _alwaysFetchTerritories) && !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 (!_territoriesReturnsNewIfNotFound)
             {
                 RemoveFromTransactionIfNecessary(newEntity);
                 newEntity = null;
             }
         }
         this.Territories           = newEntity;
         _alreadyFetchedTerritories = fetchResult;
     }
     return(_territories);
 }
コード例 #2
0
 /// <summary> setups the sync logic for member _territories</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncTerritories(IEntityCore relatedEntity)
 {
     if (_territories != relatedEntity)
     {
         DesetupSyncTerritories(true, true);
         _territories = (TerritoryEntity)relatedEntity;
         this.PerformSetupSyncRelatedEntity(_territories, new PropertyChangedEventHandler(OnTerritoriesPropertyChanged), "Territories", SD.LLBLGen.Pro.Examples.Auditing.RelationClasses.StaticEmployeeTerritoryRelations.TerritoryEntityUsingTerritoryIdStatic, true, new string[] {  });
     }
 }
コード例 #3
0
 protected EmployeeTerritoryEntity(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     if (SerializationHelper.Optimization != SerializationOptimization.Fast)
     {
         _employees = (EmployeeEntity)info.GetValue("_employees", typeof(EmployeeEntity));
         if (_employees != null)
         {
             _employees.AfterSave += new EventHandler(OnEntityAfterSave);
         }
         _territories = (TerritoryEntity)info.GetValue("_territories", typeof(TerritoryEntity));
         if (_territories != null)
         {
             _territories.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)
        {
            _employees = (EmployeeEntity)info.GetValue("_employees", typeof(EmployeeEntity));
            if (_employees != null)
            {
                _employees.AfterSave += new EventHandler(OnEntityAfterSave);
            }
            _employeesReturnsNewIfNotFound = info.GetBoolean("_employeesReturnsNewIfNotFound");
            _alwaysFetchEmployees          = info.GetBoolean("_alwaysFetchEmployees");
            _alreadyFetchedEmployees       = info.GetBoolean("_alreadyFetchedEmployees");

            _territories = (TerritoryEntity)info.GetValue("_territories", typeof(TerritoryEntity));
            if (_territories != null)
            {
                _territories.AfterSave += new EventHandler(OnEntityAfterSave);
            }
            _territoriesReturnsNewIfNotFound = info.GetBoolean("_territoriesReturnsNewIfNotFound");
            _alwaysFetchTerritories          = info.GetBoolean("_alwaysFetchTerritories");
            _alreadyFetchedTerritories       = info.GetBoolean("_alreadyFetchedTerritories");
            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 _territories</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 DesetupSyncTerritories(bool signalRelatedEntity, bool resetFKFields)
 {
     this.PerformDesetupSyncRelatedEntity(_territories, new PropertyChangedEventHandler(OnTerritoriesPropertyChanged), "Territories", SD.LLBLGen.Pro.Examples.Auditing.RelationClasses.StaticEmployeeTerritoryRelations.TerritoryEntityUsingTerritoryIdStatic, true, signalRelatedEntity, "EmployeeTerritories", resetFKFields, new int[] { (int)EmployeeTerritoryFieldIndex.TerritoryId });
     _territories = null;
 }