/// <summary> Retrieves the related entity of type 'ActivityTypeEntity', 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 'ActivityTypeEntity' which is related to this entity.</returns> public virtual ActivityTypeEntity GetSingleActivityType(bool forceFetch) { if ((!_alreadyFetchedActivityType || forceFetch || _alwaysFetchActivityType) && !this.IsSerializing && !this.IsDeserializing && !this.InDesignMode) { bool performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.ActivityTypeEntityUsingActivityTypeId); ActivityTypeEntity newEntity = new ActivityTypeEntity(); bool fetchResult = false; if (performLazyLoading) { AddToTransactionIfNecessary(newEntity); fetchResult = newEntity.FetchUsingPK(this.ActivityTypeId); } if (fetchResult) { newEntity = (ActivityTypeEntity)GetFromActiveContext(newEntity); } else { if (!_activityTypeReturnsNewIfNotFound) { RemoveFromTransactionIfNecessary(newEntity); newEntity = null; } } this.ActivityType = newEntity; _alreadyFetchedActivityType = fetchResult; } return(_activityType); }
/// <summary> setups the sync logic for member _activityType</summary> /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param> private void SetupSyncActivityType(IEntityCore relatedEntity) { if (_activityType != relatedEntity) { DesetupSyncActivityType(true, true); _activityType = (ActivityTypeEntity)relatedEntity; this.PerformSetupSyncRelatedEntity(_activityType, new PropertyChangedEventHandler(OnActivityTypePropertyChanged), "ActivityType", EPICCentralDL.RelationClasses.StaticActiveOrganizationRelations.ActivityTypeEntityUsingActivityTypeIdStatic, true, ref _alreadyFetchedActivityType, new string[] { }); } }
/// <summary>Private CTor for deserialization</summary> /// <param name="info"></param> /// <param name="context"></param> protected ActiveOrganizationEntity(SerializationInfo info, StreamingContext context) : base(info, context) { _activityType = (ActivityTypeEntity)info.GetValue("_activityType", typeof(ActivityTypeEntity)); if (_activityType != null) { _activityType.AfterSave += new EventHandler(OnEntityAfterSave); } _activityTypeReturnsNewIfNotFound = info.GetBoolean("_activityTypeReturnsNewIfNotFound"); _alwaysFetchActivityType = info.GetBoolean("_alwaysFetchActivityType"); _alreadyFetchedActivityType = info.GetBoolean("_alreadyFetchedActivityType"); _location = (LocationEntity)info.GetValue("_location", typeof(LocationEntity)); if (_location != null) { _location.AfterSave += new EventHandler(OnEntityAfterSave); } _locationReturnsNewIfNotFound = info.GetBoolean("_locationReturnsNewIfNotFound"); _alwaysFetchLocation = info.GetBoolean("_alwaysFetchLocation"); _alreadyFetchedLocation = info.GetBoolean("_alreadyFetchedLocation"); this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance()); // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor // __LLBLGENPRO_USER_CODE_REGION_END }
/// <summary> Removes the sync logic for member _activityType</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 DesetupSyncActivityType(bool signalRelatedEntity, bool resetFKFields) { this.PerformDesetupSyncRelatedEntity(_activityType, new PropertyChangedEventHandler(OnActivityTypePropertyChanged), "ActivityType", EPICCentralDL.RelationClasses.StaticActiveOrganizationRelations.ActivityTypeEntityUsingActivityTypeIdStatic, true, signalRelatedEntity, "ActiveOrganizations", resetFKFields, new int[] { (int)ActiveOrganizationFieldIndex.ActivityTypeId }); _activityType = null; }