From c325b2122b7714583e768ecc2d909ed64f8b572b Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 1 Aug 2025 13:47:22 +0200 Subject: [PATCH] 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. --- .../Entities/PObjectStateHist.cs | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/WorkFlow.Domain/Entities/PObjectStateHist.cs diff --git a/src/WorkFlow.Domain/Entities/PObjectStateHist.cs b/src/WorkFlow.Domain/Entities/PObjectStateHist.cs new file mode 100644 index 0000000..86b70d2 --- /dev/null +++ b/src/WorkFlow.Domain/Entities/PObjectStateHist.cs @@ -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; } + + /// + /// Although this field is marked as nullable in the database schema to allow + /// for greater flexibility during database-level operations or migrations, it is + /// treated as required and not null within the application logic. + /// Validation should be enforced at the application level to ensure a value is provided. + /// + [Column("MWF_PROFILE_ID", TypeName = "int")] + public int? ProfileId { get; set; } + + /// + /// Although this field is marked as nullable in the database schema to allow + /// for greater flexibility during database-level operations or migrations, it is + /// treated as required and not null within the application logic. + /// Validation should be enforced at the application level to ensure a value is provided. + /// + [Column("USR_ID", TypeName = "int")] + public int? UserId { get; set; } + + /// + /// Although this field is marked as nullable in the database schema to allow + /// for greater flexibility during database-level operations or migrations, it is + /// treated as required and not null within the application logic. + /// Validation should be enforced at the application level to ensure a value is provided. + /// + [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? TFControls { get; set; } + + public IEnumerable ToList() => new List + { + State1?.IntlState, State2, State3, State4 + }; +} \ No newline at end of file