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:
parent
69d417616d
commit
bc192e99a7
@ -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>();
|
||||
|
||||
@ -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?>
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user