/// <summary> setups the sync logic for member _controlSet</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncControlSet(IEntity relatedEntity)
 {
     if (_controlSet != relatedEntity)
     {
         DesetupSyncControlSet(true, true);
         _controlSet = (ControlSetEntity)relatedEntity;
         base.PerformSetupSyncRelatedEntity(_controlSet, new PropertyChangedEventHandler(OnControlSetPropertyChanged), "ControlSet", ControlSetColourEntity.Relations.ControlSetEntityUsingControlSetUID, true, ref _alreadyFetchedControlSet, new string[] {  });
     }
 }
        /// <summary> Initializes the class members</summary>
        private void InitClassMembers()
        {
            _controlSet = null;
            _controlSetReturnsNewIfNotFound = true;
            _alwaysFetchControlSet          = false;
            _alreadyFetchedControlSet       = false;


            PerformDependencyInjection();

            // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
            // __LLBLGENPRO_USER_CODE_REGION_END
            OnInitClassMembersComplete();
        }
        /// <summary>Protected CTor for deserialization</summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected ControlSetColourEntityBase(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            _controlSet = (ControlSetEntity)info.GetValue("_controlSet", typeof(ControlSetEntity));
            if (_controlSet != null)
            {
                _controlSet.AfterSave += new EventHandler(OnEntityAfterSave);
            }
            _controlSetReturnsNewIfNotFound = info.GetBoolean("_controlSetReturnsNewIfNotFound");
            _alwaysFetchControlSet          = info.GetBoolean("_alwaysFetchControlSet");
            _alreadyFetchedControlSet       = info.GetBoolean("_alreadyFetchedControlSet");

            base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance());

            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
        /// <summary> Retrieves the related entity of type 'ControlSetEntity', 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 'ControlSetEntity' which is related to this entity.</returns>
        public virtual ControlSetEntity GetSingleControlSet(bool forceFetch)
        {
            if ((!_alreadyFetchedControlSet || forceFetch || _alwaysFetchControlSet) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
            {
                bool performLazyLoading = base.CheckIfLazyLoadingShouldOccur(ControlSetColourEntity.Relations.ControlSetEntityUsingControlSetUID);

                ControlSetEntity newEntity = new ControlSetEntity();
                if (base.ParticipatesInTransaction)
                {
                    base.Transaction.Add(newEntity);
                }
                bool fetchResult = false;
                if (performLazyLoading)
                {
                    fetchResult = newEntity.FetchUsingPK(this.ControlSetUID);
                }
                if (fetchResult)
                {
                    if (base.ActiveContext != null)
                    {
                        newEntity = (ControlSetEntity)base.ActiveContext.Get(newEntity);
                    }
                    this.ControlSet = newEntity;
                }
                else
                {
                    if (_controlSetReturnsNewIfNotFound)
                    {
                        if (performLazyLoading || (!performLazyLoading && (_controlSet == null)))
                        {
                            this.ControlSet = newEntity;
                        }
                    }
                    else
                    {
                        this.ControlSet = null;
                    }
                }
                _alreadyFetchedControlSet = fetchResult;
                if (base.ParticipatesInTransaction && !fetchResult)
                {
                    base.Transaction.Remove(newEntity);
                }
            }
            return(_controlSet);
        }
 /// <summary>Gets the relation objects which represent the relation the fieldName specified is mapped on. </summary>
 /// <param name="fieldName">Name of the field mapped onto the relation of which the relation objects have to be obtained.</param>
 /// <returns>RelationCollection with relation object(s) which represent the relation the field is maped on</returns>
 public override RelationCollection GetRelationsForFieldOfType(string fieldName)
 {
     return(ControlSetEntity.GetRelationsForField(fieldName));
 }
 /// <summary> Removes the sync logic for member _controlSet</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 DesetupSyncControlSet(bool signalRelatedEntity, bool resetFKFields)
 {
     base.PerformDesetupSyncRelatedEntity(_controlSet, new PropertyChangedEventHandler(OnControlSetPropertyChanged), "ControlSet", ControlSetColourEntity.Relations.ControlSetEntityUsingControlSetUID, true, signalRelatedEntity, "ControlSetColourCollection", resetFKFields, new int[] { (int)ControlSetColourFieldIndex.ControlSetUID });
     _controlSet = null;
 }