public virtual void Construct(UserProfileDataObject userProfile, bool includeDirtyObjectsOnly) { if (userProfile == null) { return; } this.PrimaryKey = userProfile.PrimaryKey; if (userProfile.ObjectsDataSet == null) { var dataset = ApplicationSettings.Container.Resolve <IObjectsDataSet>(); dataset.AddObject(userProfile); } if (userProfile.ObjectsDataSet == null) { _logEngine.LogError("Unable to set a dataset to the Entity UserProfile", "Unable to set a dataset to the entity. Container may not be initialized", "UserProfileDataObject", null); throw new PulpException("Unexpected Error : Unable to set a dataset to the entity : UserProfile"); } if (userProfile.InternalObjectId == null) { _logEngine.LogError("Unable to construct an object without InternalObjectId in UserProfileDataObject", "The Object you are trying to construct doesn't have an InternalObjectId", "UserProfileDataObject", null); throw new PulpException("Unexpected Error : Unable to construct an object without InternalObjectId in UserProfileDataObject"); } this.InternalObjectId = (int)userProfile.InternalObjectId; this.ObjectsDataSet = includeDirtyObjectsOnly ? userProfile.ObjectsDataSet.CloneDirtyObjects() : userProfile.ObjectsDataSet; }
public IEnumerable <GOUserDataObject> GetGOUserForUserProfile(UserProfileDataObject userProfileInstance) { if (userProfileInstance.IsNew) { return(GOUserObjects.Where(o => o.Value._userProfile_NewObjectId != null && o.Value._userProfile_NewObjectId == userProfileInstance.InternalObjectId).Select(o => o.Value)); } if (UserProfile_FKIndex.ContainsKey(userProfileInstance.Uri)) { return(UserProfile_FKIndex[userProfileInstance.Uri].Where(e => GOUserObjects.ContainsKey(e)).Select(e => GOUserObjects[e])); } return(new DataObjectCollection <GOUserDataObject>()); }
public IEnumerable<VisitedPlaceDataObject> GetVisitedPlaceItemsForUserProfile(UserProfileDataObject userProfileInstance) { if (userProfileInstance.IsNew) { return VisitedPlaceObjects.Where(o => o.Value._userProfile_NewObjectId != null && o.Value._userProfile_NewObjectId == userProfileInstance.InternalObjectId).Select(o => o.Value); } if (UserProfile_FKIndex.ContainsKey(userProfileInstance.Uri)) { return UserProfile_FKIndex[userProfileInstance.Uri].Where(e => VisitedPlaceObjects.ContainsKey(e)).Select(e => VisitedPlaceObjects[e]); } return new DataObjectCollection<VisitedPlaceDataObject>(); }
protected void SetRelations(UserProfileDataObject x) { var prefetches = PrefetchAssociations.Get("UserProfile", ApplicationSettings.Resolve <IDataProviderTransaction>()?.Parameters); if (prefetches.Contains("GOUser") && this.GOUser != null) { var gOUser = x.ObjectsDataSet.GetObject(new GOUserDataObject((System.Guid) this.GOUser.Id) { IsNew = false }); if (gOUser == null) { gOUser = this.GOUser.ToDataObject(x.ObjectsDataSet) as GOUserDataObject; } x.SetGOUserValue(gOUser); } }
/// <summary> /// Copy Constructor /// </summary> public UserProfileDataObject(UserProfileDataObject template, bool deepCopy) { this.SetNameValue(template.Name, false, false); this.SetOrganizationNameValue(template.OrganizationName, false, false); this.SetRoleValue(template.Role, 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); }
/// /// All FK-Side Relations /// /// /// PK-Side one-to-many relations /// // public virtual IList<ORMVisitedPlace> VisitedPlaceItems { get; set; } = new List<ORMVisitedPlace>();VisitedPlace is not mapped to the database /// /// Bridge to DataObject /// public virtual IDataObject ToDataObject(IObjectsDataSet dataset) { var session = NHibernateSessionController.GetCurrentSession(); session.Evict(this); var x = new UserProfileDataObject(); SetProperties(x); x.IsDirty = x.IsNew = x.IsMarkedForDeletion = false; x.ObjectsDataSet = dataset; x.ObjectsDataSet.AddObjectIfDoesNotExist(x); // Deep-map prefetch relations if (PrefetchAssociations.HasPrefetchForEntity("UserProfile", ApplicationSettings.Resolve <IDataProviderTransaction>()?.Parameters)) { SetRelations(x); } return(x); }
public UserProfileContainer(UserProfileDataObject userProfile, bool includeDirtyObjectsOnly) { Construct(userProfile, includeDirtyObjectsOnly); }
public UserProfileContainer(UserProfileDataObject userProfile) { Construct(userProfile, false); }
protected void SetProperties(UserProfileDataObject x) { x.SetUriValue(Uri, false, false); }
public virtual void SetUserProfileValue(UserProfileDataObject valueToSet, bool notifyChanges, bool dirtyHandlerOn) { UserProfileDataObject existing_userProfile = null; if (!(this.UserProfileUri == null || ObjectsDataSet == null)) { var key = this._userProfile_NewObjectId == null ? new UserProfileDataObject(this.UserProfileUri) { IsNew = false } : new UserProfileDataObject() { IsNew = true, InternalObjectId = this._userProfile_NewObjectId }; existing_userProfile = (UserProfileDataObject)ObjectsDataSet.GetObject(key); } if (ReferenceEquals(existing_userProfile, valueToSet)) { return; } // Give opportunity to change value before set OnBeforeSetRelationField("UserProfile", 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 (_userProfile_NewObjectId != valueToSet.InternalObjectId) { _userProfile_NewObjectId = valueToSet.InternalObjectId; _userProfileUri = valueToSet.Uri; OnPropertyChanged("UserProfileUri", notifyChanges, dirtyHandlerOn); } } else { if (_userProfileUri != valueToSet.Uri) { _userProfile_NewObjectId = null; _userProfileUri = valueToSet.Uri; OnPropertyChanged("UserProfileUri", notifyChanges, dirtyHandlerOn); } } } else { _userProfileUri = null; OnPropertyChanged("UserProfileUri", notifyChanges, dirtyHandlerOn); } if (!ReferenceEquals(existing_userProfile, valueToSet)) { OnPropertyChanged("UserProfile", notifyChanges, dirtyHandlerOn); } }
public virtual void SetUserProfileValue(UserProfileDataObject valueToSet) { SetUserProfileValue(valueToSet, true, true); }