Refactor ObjectDto and update PObjectState relationships

Removed ObjStateId and Id from ObjectDto for simplification.
Updated foreign key in PObjectState from ObjStateId to StateId,
and modified TFControls to support nullable collections.
Adjusted WFDBContext configuration for clearer foreign key
relationships and improved maintainability of the database schema.
This commit is contained in:
tekh 2025-08-01 12:53:56 +02:00
parent 69d417616d
commit bc192e99a7
3 changed files with 4 additions and 7 deletions

View File

@ -2,8 +2,6 @@
public class ObjectDto
{
public long? ObjStateId { get; set; }
public long? Id { get; set; }
public IEnumerable<string> Headlines { get; set; } = Array.Empty<string>();

View File

@ -79,10 +79,10 @@ public class PObjectState
[Column("CHANGED_WHEN", TypeName = "datetime")]
public DateTime? ChangedWhen { get; set; }
[ForeignKey("ObjStateId")]
[ForeignKey("StateId")]
public virtual State? State1 { get; set; }
public IEnumerable<PControlsTF> TFControls { get; set; } = Array.Empty<PControlsTF>();
public virtual IEnumerable<PControlsTF>? TFControls { get; set; }
public IEnumerable<string?> ToList() => new List<string?>
{

View File

@ -47,10 +47,9 @@ public class WFDBContext : DbContext, IUserManagerDbContext
modelBuilder.ConfigureUserManager();
modelBuilder.Entity<PObjectState>()
.HasMany(pos => pos.TFControls)
.HasMany(objState => objState.TFControls)
.WithOne()
.HasForeignKey(pctf => pctf.ObjStateId)
.HasPrincipalKey(pos => pos.Id)
.HasForeignKey(control => control.ObjStateId)
.OnDelete(DeleteBehavior.Cascade);
base.OnModelCreating(modelBuilder);