using System.Text; namespace Quadarax.Foundation.Core.Data.Transaction { /// /// Represents a single data change transaction for an entity property. /// Tracks the type of change, the property affected, and the associated value. /// public class DataTransaction { #region *** Enumerations *** /// /// Defines the types of data change operations. /// public enum TransactionTypeEnum { /// /// Indicates a new property or entity has been added. /// Add, /// /// Indicates a property or entity has been removed. /// Remove, /// /// Indicates a property value has been modified. /// Change } #endregion #region *** Properties *** /// /// Gets the name of the property that was changed. /// public string PropertyName { get; private set; } /// /// Gets the type of transaction (Add, Remove, or Change). /// public TransactionTypeEnum TransactionType { get; private set; } /// /// Gets the value associated with the transaction. /// May be null for Remove operations. /// public string? Value { get; private set; } /// /// Gets a value indicating whether the Value property contains a reference key /// rather than a direct property value. /// /// When true, the Value represents a reference to another entity (foreign key). /// When false, the Value represents the actual property value. /// public bool IsValueKey { get; private set; } #endregion #region *** Constructor *** /// /// Initializes a new instance of the DataTransaction class. /// /// The name of the property that was changed. /// The type of transaction (Add/Remove/Change). /// The new value of the property, or null if the property was removed. /// True if the value represents a reference key; otherwise, false. public DataTransaction(string propertyName, TransactionTypeEnum transactionType, string? value, bool isValueKey) { PropertyName = propertyName; TransactionType = transactionType; Value = value; IsValueKey = isValueKey; } #endregion #region *** Public Overrides *** /// /// Returns a string representation of the data transaction. /// /// A formatted string containing the transaction details. public override string ToString() { var sb = new StringBuilder(); sb.Append("Type=").Append(TransactionType).Append(";"); sb.Append("Field=").Append(PropertyName).Append(";"); sb.Append("Value=").Append(Value == null ? "" : Value).Append(";"); return sb.ToString(); } #endregion } }