예제 #1
0
 /// <summary>
 /// Internal use
 /// </summary>
 public UserProfile ShallowCopy(bool allData = false, bool preserveState = false, bool checkLoadState = false)
 {
     UserProfile e = new UserProfile();
     e.StartAutoUpdating = false;
     e.ID = ID;
     e.PropName = PropName;
     e.LastAccessTime = LastAccessTime;
     if (preserveState)
         e.IsLastAccessTimeModified = IsLastAccessTimeModified;
     else
         e.IsLastAccessTimeModified = false;
     e.LastUpdateTime = LastUpdateTime;
     if (preserveState)
         e.IsLastUpdateTimeModified = IsLastUpdateTimeModified;
     else
         e.IsLastUpdateTimeModified = false;
     e.ValueMimeType = ValueMimeType;
     if (preserveState)
         e.IsValueMimeTypeModified = IsValueMimeTypeModified;
     else
         e.IsValueMimeTypeModified = false;
     e.ApplicationID = ApplicationID;
     e.TypeID = TypeID;
     e.UserID = UserID;
     if (allData)
     {
         if (!checkLoadState || IsBinaryValueLoaded)
             e.BinaryValue = BinaryValue;
         if (preserveState)
             e.IsBinaryValueModified = IsBinaryValueModified;
         else
             e.IsBinaryValueModified = false;
         e.IsBinaryValueLoaded = IsBinaryValueLoaded;
         if (!checkLoadState || IsStringValueLoaded)
             e.StringValue = StringValue;
         if (preserveState)
             e.IsStringValueModified = IsStringValueModified;
         else
             e.IsStringValueModified = false;
         e.IsStringValueLoaded = IsStringValueLoaded;
     }
     e.DistinctString = GetDistinctString(true);
     e.IsPersisted = IsPersisted;
     if (preserveState)
         e.IsEntityChanged = IsEntityChanged;
     else
         e.IsEntityChanged = false;
     e.StartAutoUpdating = true;
     return e;
 }
예제 #2
0
 /// <summary>
 /// Update changes to the current entity compared to an input <paramref name="newdata" /> and set the entity to a proper state for updating.
 /// </summary>
 /// <param name="newdata">The "new" entity acting as the source of the changes, if any.</param>
 /// <returns>
 /// </returns>
 public void UpdateChanges(UserProfile newdata)
 {
     int cnt = 0;
     bool bBinaryValue = BinaryValue == null && newdata.BinaryValue != null ||
                                                  BinaryValue != null && newdata.BinaryValue == null ||
                                                  BinaryValue != null && newdata.BinaryValue != null && BinaryValue.Length != newdata.BinaryValue.Length;
     if (!bBinaryValue && BinaryValue != null)
     {
         for (int i = 0; i < BinaryValue.Length; i++)
         {
             bBinaryValue = BinaryValue[i] != newdata.BinaryValue[i];
             if (bBinaryValue)
                 break;
         }
     }
     if (bBinaryValue)
     {
         BinaryValue = newdata.BinaryValue;
         IsBinaryValueModified = true;
         cnt++;
     }
     if (LastAccessTime != newdata.LastAccessTime)
     {
         LastAccessTime = newdata.LastAccessTime;
         IsLastAccessTimeModified = true;
         cnt++;
     }
     if (LastUpdateTime != newdata.LastUpdateTime)
     {
         LastUpdateTime = newdata.LastUpdateTime;
         IsLastUpdateTimeModified = true;
         cnt++;
     }
     if (StringValue != newdata.StringValue)
     {
         StringValue = newdata.StringValue;
         IsStringValueModified = true;
         cnt++;
     }
     if (ValueMimeType != newdata.ValueMimeType)
     {
         ValueMimeType = newdata.ValueMimeType;
         IsValueMimeTypeModified = true;
         cnt++;
     }
     IsEntityChanged = cnt > 0;
 }
예제 #3
0
 /// <summary>
 /// Merge changes inside entity <paramref name="from" /> to the entity <paramref name="to" />. Any changes in <paramref name="from" /> that is not changed in <paramref name="to" /> is updated inside <paramref name="to" />.
 /// </summary>
 /// <param name="from">The "old" entity acting as merging source.</param>
 /// <param name="to">The "new" entity which inherits changes made in <paramref name="from" />.</param>
 /// <returns>
 /// </returns>
 public static void MergeChanges(UserProfile from, UserProfile to)
 {
     if (to.IsPersisted)
     {
         if (from.IsBinaryValueModified && !to.IsBinaryValueModified)
         {
             to.BinaryValue = from.BinaryValue;
             to.IsBinaryValueModified = true;
         }
         if (from.IsLastAccessTimeModified && !to.IsLastAccessTimeModified)
         {
             to.LastAccessTime = from.LastAccessTime;
             to.IsLastAccessTimeModified = true;
         }
         if (from.IsLastUpdateTimeModified && !to.IsLastUpdateTimeModified)
         {
             to.LastUpdateTime = from.LastUpdateTime;
             to.IsLastUpdateTimeModified = true;
         }
         if (from.IsStringValueModified && !to.IsStringValueModified)
         {
             to.StringValue = from.StringValue;
             to.IsStringValueModified = true;
         }
         if (from.IsValueMimeTypeModified && !to.IsValueMimeTypeModified)
         {
             to.ValueMimeType = from.ValueMimeType;
             to.IsValueMimeTypeModified = true;
         }
     }
     else
     {
         to.IsPersisted = from.IsPersisted;
         to.ID = from.ID;
         to.PropName = from.PropName;
         to.BinaryValue = from.BinaryValue;
         to.IsBinaryValueModified = from.IsBinaryValueModified;
         to.LastAccessTime = from.LastAccessTime;
         to.IsLastAccessTimeModified = from.IsLastAccessTimeModified;
         to.LastUpdateTime = from.LastUpdateTime;
         to.IsLastUpdateTimeModified = from.IsLastUpdateTimeModified;
         to.StringValue = from.StringValue;
         to.IsStringValueModified = from.IsStringValueModified;
         to.ValueMimeType = from.ValueMimeType;
         to.IsValueMimeTypeModified = from.IsValueMimeTypeModified;
         to.ApplicationID = from.ApplicationID;
         to.TypeID = from.TypeID;
         to.UserID = from.UserID;
     }
 }
예제 #4
0
 /// <summary>
 /// Whether or not the present entity is identitical to <paramref name="other" />, in the sense that they have the same (set of) intrinsic identifiers.
 /// </summary>
 /// <param name="other">The entity to be compared to.</param>
 /// <returns>
 ///   The result of comparison.
 /// </returns>
 public bool IsEntityTheSame(UserProfile other)
 {
     if (other == null)
         return false;
     else
         return PropName == other.PropName &&  ApplicationID == other.ApplicationID &&  UserID == other.UserID;
 }              
예제 #5
0
 /// <summary>
 /// Whether or not the present entity is identitical to <paramref name="other" />, in the sense that they have the same (set of) primary key(s).
 /// </summary>
 /// <param name="other">The entity to be compared to.</param>
 /// <returns>
 ///   The result of comparison.
 /// </returns>
 public bool IsEntityIdentical(UserProfile other)
 {
     if (other == null)
         return false;
     if (ID != other.ID)
         return false;
     return true;
 }              
예제 #6
0
 /// <summary>
 /// Internal use
 /// </summary>
 public UserProfile ShallowCopy(bool allData = false)
 {
     UserProfile e = new UserProfile();
     e.IsInitializing = true;
     e.ID = ID;
     e.PropName = PropName;
     e.LastAccessTime = LastAccessTime;
     e.LastUpdateTime = LastUpdateTime;
     e.ValueMimeType = ValueMimeType;
     e.ApplicationID = ApplicationID;
     e.TypeID = TypeID;
     e.UserID = UserID;
     if (allData)
     {
         e.BinaryValue = BinaryValue;
         e.StringValue = StringValue;
     }
     e.DistinctString = GetDistinctString(true);
     e.IsPersisted = true;
     e.IsEntityChanged = false;
     e.IsInitializing = false;
     return e;
 }