public virtual void Construct(CountryDataObject country, bool includeDirtyObjectsOnly)
        {
            if (country == null)
            {
                return;
            }

            this.PrimaryKey = country.PrimaryKey;

            if (country.ObjectsDataSet == null)
            {
                var dataset = ApplicationSettings.Container.Resolve <IObjectsDataSet>();
                dataset.AddObject(country);
            }

            if (country.ObjectsDataSet == null)
            {
                _logEngine.LogError("Unable to set a dataset to the Entity Country", "Unable to set a dataset to the entity. Container may not be initialized", "CountryDataObject", null);
                throw new PulpException("Unexpected Error : Unable to set a dataset to the entity : Country");
            }

            if (country.InternalObjectId == null)
            {
                _logEngine.LogError("Unable to construct an object without InternalObjectId in CountryDataObject", "The Object you are trying to construct doesn't have an InternalObjectId", "CountryDataObject", null);
                throw new PulpException("Unexpected Error : Unable to construct an object without InternalObjectId in CountryDataObject");
            }
            this.InternalObjectId = (int)country.InternalObjectId;
            this.ObjectsDataSet   = includeDirtyObjectsOnly ? country.ObjectsDataSet.CloneDirtyObjects() : country.ObjectsDataSet;
        }
        /// <summary>
        /// Copy Constructor
        /// </summary>
        public CountryDataObject(CountryDataObject template, bool deepCopy)
        {
            this.SetAbstractValue(template.Abstract, false, false);
            this.SetFlagValue(template.Flag, false, false);
            this.SetLongNameValue(template.LongName, false, false);
            this.SetNameValue(template.Name, false, false);
            this.SetPopulationDensityValue(template.PopulationDensity, false, false);
            this.SetPopulationTotalValue(template.PopulationTotal, false, false);
            this.SetURIValue(template.URI, false, false);


            this.SetIsNewValue(template.IsNew, false, false);

            if (deepCopy)
            {
                this.ObjectsDataSet = template.ObjectsDataSet.Clone();
                // Remove the template object from the dataset
                this.ObjectsDataSet.RemoveObject(template);
                // And Replace by the one we're currently constructing
                this.ObjectsDataSet.AddObject(this);
            }

            this.SetIsDirtyValue(template.IsDirty, false, false);
            this.SetIsMarkedForDeletionValue(template.IsMarkedForDeletion, false, false);
        }
Exemple #3
0
		public IEnumerable<VisitedPlaceDataObject> GetVisitedPlaceItemsForCountry(CountryDataObject countryInstance) 
		{
			if (countryInstance.IsNew)
            {
			
              return VisitedPlaceObjects.Where(o => o.Value._country_NewObjectId != null && o.Value._country_NewObjectId == countryInstance.InternalObjectId).Select(o => o.Value);
			}
				
			if (Country_FKIndex.ContainsKey(countryInstance.URI))
			{
				return Country_FKIndex[countryInstance.URI].Where(e => VisitedPlaceObjects.ContainsKey(e)).Select(e => VisitedPlaceObjects[e]);
			}
			
			return new DataObjectCollection<VisitedPlaceDataObject>();
		}
 public CountryContainer(CountryDataObject country, bool includeDirtyObjectsOnly)
 {
     Construct(country, includeDirtyObjectsOnly);
 }
 public CountryContainer(CountryDataObject country)
 {
     Construct(country, false);
 }
        public virtual void SetCountryValue(CountryDataObject valueToSet, bool notifyChanges, bool dirtyHandlerOn)
        {
            CountryDataObject existing_country = null;

            if (!(this.CountryURI == null || ObjectsDataSet == null))
            {
                var key = this._country_NewObjectId == null ? new CountryDataObject((System.String) this.CountryURI)
                {
                    IsNew = false
                } : new CountryDataObject()
                {
                    IsNew = true, InternalObjectId = this._country_NewObjectId
                };
                existing_country = (CountryDataObject)ObjectsDataSet.GetObject(key);
            }

            if (ReferenceEquals(existing_country, valueToSet))
            {
                if (valueToSet == null)
                {
                    _country_NewObjectId = null;
                    _countryURI          = null;
                }
                return;
            }
            // Give opportunity to change value before set
            OnBeforeSetRelationField("Country", valueToSet);

            // Setting the navigator desync the FK. The FK should be resync
            if (!ReferenceEquals(null, valueToSet))
            {
                if (ObjectsDataSet == null)
                {
                    _logEngine.LogError("Unable to set Relation Field", "Unable to set Relation Field, your entity doesn't have a DataSet.", "VisitedPlaceDataObject", null);
                    throw new PulpException("Unable to set Relation fields, your entity doesn't have a DataSet");
                }

                ObjectsDataSet.AddObjectIfDoesNotExist(valueToSet);

                if (valueToSet.IsNew)
                {
                    if (_country_NewObjectId != valueToSet.InternalObjectId)
                    {
                        _country_NewObjectId = valueToSet.InternalObjectId;
                        _countryURI          = valueToSet.URI;
                        OnPropertyChanged("CountryURI", notifyChanges, dirtyHandlerOn);
                    }
                }
                else
                {
                    if (_countryURI != valueToSet.URI)
                    {
                        _country_NewObjectId = null;

                        _countryURI = valueToSet.URI;
                        OnPropertyChanged("CountryURI", notifyChanges, dirtyHandlerOn);
                    }
                }
            }
            else
            {
                _country_NewObjectId = null;
                _countryURI          = null;

                OnPropertyChanged("CountryURI", notifyChanges, dirtyHandlerOn);
            }
            if (!ReferenceEquals(existing_country, valueToSet))
            {
                OnPropertyChanged("Country", notifyChanges, dirtyHandlerOn);
            }
        }
 public virtual void SetCountryValue(CountryDataObject valueToSet)
 {
     SetCountryValue(valueToSet, true, true);
 }