Add PObjectStateHist class for state history tracking

Introduces the `PObjectStateHist` class in the `WorkFlow.Domain.Entities` namespace, mapped to the `TBMWF_PROFILE_OBJ_STATE_HISTORY` table. The class includes properties with data annotations for validation and schema mapping, addressing nullable fields treated as required in application logic. A `ToList()` method is added to return state-related strings, enhancing functionality.
This commit is contained in:
tekh 2025-08-01 13:47:22 +02:00
parent 63adb51263
commit c325b2122b

View File

@ -0,0 +1,72 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace WorkFlow.Domain.Entities;
[Table("TBMWF_PROFILE_OBJ_STATE_HISTORY", Schema = "dbo")]
public class PObjectStateHist
{
[Key]
[Column("GUID", TypeName = "bigint")]
public long Id { get; set; }
/// <summary>
/// Although this field is marked as <c>nullable</c> in the database schema to allow
/// for greater flexibility during database-level operations or migrations, it is
/// treated as <c>required</c> and <c>not null</c> within the application logic.
/// Validation should be enforced at the application level to ensure a value is provided.
/// </summary>
[Column("MWF_PROFILE_ID", TypeName = "int")]
public int? ProfileId { get; set; }
/// <summary>
/// Although this field is marked as <c>nullable</c> in the database schema to allow
/// for greater flexibility during database-level operations or migrations, it is
/// treated as <c>required</c> and <c>not null</c> within the application logic.
/// Validation should be enforced at the application level to ensure a value is provided.
/// </summary>
[Column("USR_ID", TypeName = "int")]
public int? UserId { get; set; }
/// <summary>
/// Although this field is marked as <c>nullable</c> in the database schema to allow
/// for greater flexibility during database-level operations or migrations, it is
/// treated as <c>required</c> and <c>not null</c> within the application logic.
/// Validation should be enforced at the application level to ensure a value is provided.
/// </summary>
[Column("OBJ_ID", TypeName = "bigint")]
public long? ObjectId { get; set; }
[Required]
[Column("STATE_ID", TypeName = "int")]
public int StateId { get; set; }
[Column("STATE2", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string? State2 { get; set; }
[Column("STATE3", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string? State3 { get; set; }
[Column("STATE4", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string? State4 { get; set; }
[Column("CHANGED_WHO", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string? ChangedWho { get; set; }
[Column("CHANGED_WHEN", TypeName = "datetime")]
public DateTime? ChangedWhen { get; set; }
[ForeignKey("StateId")]
public virtual State? State1 { get; set; }
public virtual IEnumerable<PControlsTF>? TFControls { get; set; }
public IEnumerable<string?> ToList() => new List<string?>
{
State1?.IntlState, State2, State3, State4
};
}