Refactor ProfileObjState properties and add documentation

- Changed properties from `init` to `set` for mutability.
- Updated `ProfileId`, `UserId`, `ObjId`, and `StateId` to nullable types.
- Added XML documentation for clarity on property usage.
- Reduced maximum length of `State2`, `State3`, and `State4` to 100 characters.
- Modified `AddedWho` to nullable with default value "SYS".
- Changed `AddedWhen` to nullable with default value of `DateTime.Now`.
- Introduced `ChangedWho` and `ChangedWhen` properties for tracking changes.
- Updated navigation properties to reflect new accessors.
This commit is contained in:
tekh 2025-08-01 02:11:49 +02:00
parent c779dd4a47
commit 8f2261f0fa

View File

@ -1,5 +1,4 @@
using DigitalData.UserManager.Domain.Entities;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace WorkFlow.Domain.Entities;
@ -8,48 +7,84 @@ namespace WorkFlow.Domain.Entities;
public class ProfileObjState
{
[Key]
[Column("GUID")]
public long Id { get; init; }
[Column("GUID", TypeName = "bigint")]
public long Id { get; set; }
[Required]
[Column("MWF_PROFILE_ID")]
public required int ProfileId { get; init; }
/// <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; }
[Required]
[Column("USR_ID")]
public required int UserId { get; init; }
/// <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; }
[Required]
[Column("OBJ_ID")]
public required long ObjId { get; init; }
/// <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")]
public required int StateId { get; init; }
/// <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("STATE_ID", TypeName = "int")]
public int? StateId { get; set; }
[Column("STATE2", TypeName = "nvarchar(3000)")]
public string? State2 { get; init; }
[Column("STATE2", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string? State2 { get; set; }
[Column("STATE3", TypeName = "nvarchar(3000)")]
public string? State3 { get; init; }
[Column("STATE3", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string? State3 { get; set; }
[Column("STATE4", TypeName = "nvarchar(3000)")]
public string? State4 { get; init; }
[Column("STATE4", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string? State4 { get; set; }
[Required]
[Column("ADDED_WHO", TypeName = "varchar(30)")]
public required string AddedWho { get; init; }
/// <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("ADDED_WHO", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string? AddedWho { get; set; } = "SYS";
[Required]
/// <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("ADDED_WHEN", TypeName = "datetime")]
public required DateTime AddedWhen { get; init; }
public DateTime? AddedWhen { get; set; } = DateTime.Now;
[ForeignKey("ProfileId")]
public Profile? Profile { get; init; } = null;
[Column("CHANGED_WHO", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string? ChangedWho { get; set; }
[ForeignKey("UserId")]
public User? User { get; init; } = null;
[Column("CHANGED_WHEN", TypeName = "datetime")]
public DateTime? ChangedWhen { get; set; }
[ForeignKey("StateId")]
public State? State { get; init; } = null;
}
public virtual State? State { get; set; }
}