/// <summary>Creates a new, empty DonorEntity object.</summary>
        /// <returns>A new, empty DonorEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new DonorEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewDonor
            // __LLBLGENPRO_USER_CODE_REGION_END

            return toReturn;
        }
 /// <summary> Removes the sync logic for member _donor</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 DesetupSyncDonor(bool signalRelatedEntity, bool resetFKFields)
 {
     base.PerformDesetupSyncRelatedEntity( _donor, new PropertyChangedEventHandler( OnDonorPropertyChanged ), "Donor", AuctionEventDonorEntity.Relations.DonorEntityUsingDonorId, true, signalRelatedEntity, "AuctionEventDonor", resetFKFields, new int[] { (int)AuctionEventDonorFieldIndex.DonorId } );
     _donor = null;
 }
        /// <summary> Initializes the class members</summary>
        private void InitClassMembers()
        {
            _auctionEvent = null;
            _auctionEventReturnsNewIfNotFound = true;
            _alwaysFetchAuctionEvent = false;
            _alreadyFetchedAuctionEvent = false;
            _donor = null;
            _donorReturnsNewIfNotFound = true;
            _alwaysFetchDonor = false;
            _alreadyFetchedDonor = false;

            PerformDependencyInjection();

            // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
            // __LLBLGENPRO_USER_CODE_REGION_END

            OnInitClassMembersComplete();
        }
        /// <summary> Retrieves the related entity of type 'DonorEntity', 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 'DonorEntity' which is related to this entity.</returns>
        public virtual DonorEntity GetSingleDonor(bool forceFetch)
        {
            if( ( !_alreadyFetchedDonor || forceFetch || _alwaysFetchDonor) && !base.IsSerializing && !base.IsDeserializing  && !base.InDesignMode)
            {
                bool performLazyLoading = base.CheckIfLazyLoadingShouldOccur(AuctionEventDonorEntity.Relations.DonorEntityUsingDonorId);

                DonorEntity newEntity = new DonorEntity();
                if(base.ParticipatesInTransaction)
                {
                    base.Transaction.Add(newEntity);
                }
                bool fetchResult = false;
                if(performLazyLoading)
                {
                    fetchResult = newEntity.FetchUsingPK(this.DonorId);
                }
                if(fetchResult)
                {
                    if(base.ActiveContext!=null)
                    {
                        newEntity = (DonorEntity)base.ActiveContext.Get(newEntity);
                    }
                    this.Donor = newEntity;
                }
                else
                {
                    if(_donorReturnsNewIfNotFound)
                    {
                        if(performLazyLoading || (!performLazyLoading && (_donor == null)))
                        {
                            this.Donor = newEntity;
                        }
                    }
                    else
                    {
                        this.Donor = null;
                    }
                }
                _alreadyFetchedDonor = fetchResult;
                if(base.ParticipatesInTransaction && !fetchResult)
                {
                    base.Transaction.Remove(newEntity);
                }
            }
            return _donor;
        }
        /// <summary>Private CTor for deserialization</summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected AuctionEventDonorEntity(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            _auctionEvent = (AuctionEventEntity)info.GetValue("_auctionEvent", typeof(AuctionEventEntity));
            if(_auctionEvent!=null)
            {
                _auctionEvent.AfterSave+=new EventHandler(OnEntityAfterSave);
            }
            _auctionEventReturnsNewIfNotFound = info.GetBoolean("_auctionEventReturnsNewIfNotFound");
            _alwaysFetchAuctionEvent = info.GetBoolean("_alwaysFetchAuctionEvent");
            _alreadyFetchedAuctionEvent = info.GetBoolean("_alreadyFetchedAuctionEvent");
            _donor = (DonorEntity)info.GetValue("_donor", typeof(DonorEntity));
            if(_donor!=null)
            {
                _donor.AfterSave+=new EventHandler(OnEntityAfterSave);
            }
            _donorReturnsNewIfNotFound = info.GetBoolean("_donorReturnsNewIfNotFound");
            _alwaysFetchDonor = info.GetBoolean("_alwaysFetchDonor");
            _alreadyFetchedDonor = info.GetBoolean("_alreadyFetchedDonor");

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

            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
 /// <summary> setups the sync logic for member _donor</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncDonor(IEntity relatedEntity)
 {
     if(_donor!=relatedEntity)
     {
         DesetupSyncDonor(true, true);
         _donor = (DonorEntity)relatedEntity;
         base.PerformSetupSyncRelatedEntity( _donor, new PropertyChangedEventHandler( OnDonorPropertyChanged ), "Donor", AuctionEventDonorEntity.Relations.DonorEntityUsingDonorId, true, ref _alreadyFetchedDonor, new string[] {  } );
     }
 }
 public void Update(ref Auction.Domain.Donor donor,
                    ref IAuctionTransaction trans)
 {
     var d = new DonorEntity
     {
         Notes = donor.Notes,
         Name = donor.Name,
         AccountId = donor.AccountId,
         Phone = donor.Phone,
         UpdatedBy = donor.UpdatedBy
     };
     using (var donors = new DonorCollection())
     {
         donors.UpdateMulti(d, new PredicateExpression {DonorFields.Id == donor.Id});
     }
 }
 public void Insert(ref Auction.Domain.Donor donor,
                    ref IAuctionTransaction trans)
 {
     var d = new DonorEntity
                 {
                     Notes = donor.Notes,
                     Name = donor.Name,
                     AccountId = donor.AccountId,
                     Phone = donor.Phone,
                     CreatedBy = donor.CreatedBy,
                     UpdatedBy = donor.UpdatedBy
                 };
     d.Save();
 }