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

            this.PrimaryKey = gOUserRole.PrimaryKeysCollection;

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

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

            if (gOUserRole.InternalObjectId == null)
            {
                _logEngine.LogError("Unable to construct an object without InternalObjectId in GOUserRoleDataObject", "The Object you are trying to construct doesn't have an InternalObjectId", "GOUserRoleDataObject", null);
                throw new PulpException("Unexpected Error : Unable to construct an object without InternalObjectId in GOUserRoleDataObject");
            }
            this.InternalObjectId = (int)gOUserRole.InternalObjectId;
            this.ObjectsDataSet   = includeDirtyObjectsOnly ? gOUserRole.ObjectsDataSet.CloneDirtyObjects() : gOUserRole.ObjectsDataSet;
        }
Example #2
0
        protected void SetRelations(GOUserRoleDataObject x)
        {
            var prefetches = PrefetchAssociations.Get("GOUserRole", ApplicationSettings.Resolve <IDataProviderTransaction>()?.Parameters);

            if (prefetches.Contains("User") && this.User != null)
            {
                var user = x.ObjectsDataSet.GetObject(new GOUserDataObject((System.Guid) this.User.Id)
                {
                    IsNew = false
                });

                if (user == null)
                {
                    user = this.User.ToDataObject(x.ObjectsDataSet) as GOUserDataObject;
                }

                x.SetUserValue(user);
            }
        }
        /// <summary>
        /// Copy Constructor
        /// </summary>
        public GOUserRoleDataObject(GOUserRoleDataObject template, bool deepCopy)
        {
            this.SetGORoleNameValue(template.GORoleName, false, false);
            this.SetGOUserIdValue(template.GOUserId, false, false);

            this._role_NewObjectId = template._role_NewObjectId;

            this._user_NewObjectId = template._user_NewObjectId;

            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);
        }
Example #4
0
        ///
        /// Composite PK routings
        ///

        ///
        /// PK-Side one-to-many relations
        ///

        ///
        /// Bridge to DataObject
        ///
        public virtual IDataObject ToDataObject(IObjectsDataSet dataset)
        {
            var session = NHibernateSessionController.GetCurrentSession();

            session.Evict(this);

            var x = new GOUserRoleDataObject();

            SetProperties(x);

            x.IsDirty = x.IsNew = x.IsMarkedForDeletion = false;

            x.ObjectsDataSet = dataset;
            x.ObjectsDataSet.AddObjectIfDoesNotExist(x);

            // Deep-map prefetch relations
            if (PrefetchAssociations.HasPrefetchForEntity("GOUserRole", ApplicationSettings.Resolve <IDataProviderTransaction>()?.Parameters))
            {
                SetRelations(x);
            }

            return(x);
        }
 public GOUserRoleContainer(GOUserRoleDataObject gOUserRole, bool includeDirtyObjectsOnly)
 {
     Construct(gOUserRole, includeDirtyObjectsOnly);
 }
 public GOUserRoleContainer(GOUserRoleDataObject gOUserRole)
 {
     Construct(gOUserRole, false);
 }
Example #7
0
 protected void SetProperties(GOUserRoleDataObject x)
 {
     x.SetGOUserIdValue(this.GOUserId, false, false);
     x.SetGORoleNameValue(this.GORoleName, false, false);
 }