refactor: Beziehung zwischen „Object“ und „History“ hinzufügen.
This commit is contained in:
parent
ec975a2bc3
commit
9d07b1e71c
@ -9,4 +9,6 @@ public class ObjectDto
|
||||
public string? CmdCheckIn { get; set; }
|
||||
|
||||
public ObjectStateDto? State { get; set; }
|
||||
|
||||
public IEnumerable<ObjectStateHistDto> StateHistories { get; set; } = Array.Empty<ObjectStateHistDto>();
|
||||
}
|
||||
|
||||
@ -28,6 +28,5 @@ public class PObject
|
||||
[ForeignKey("ObjStateId")]
|
||||
public virtual PObjectState? State { get; set; }
|
||||
|
||||
[ForeignKey("ObjStateId")]
|
||||
public virtual IEnumerable<PObjectStateHist>? StateHistory { get; set; } = Array.Empty<PObjectStateHist>();
|
||||
public virtual IEnumerable<PObjectStateHist>? StateHistories { get; set; }
|
||||
}
|
||||
@ -62,6 +62,4 @@ public class PObjectStateHist
|
||||
|
||||
[ForeignKey("StateId")]
|
||||
public virtual State? State1 { get; set; }
|
||||
|
||||
public virtual IEnumerable<PControlsTF>? TFControls { get; set; }
|
||||
}
|
||||
@ -37,5 +37,6 @@ public class PObjectRepository : IProfileObjRepository
|
||||
.FromSqlRaw("SELECT * FROM [FNMWF_GET_PROFILE_OBJECTS] ({0}, {1})", userId, profileId)
|
||||
.Include(obj => obj.State).ThenInclude(objState => objState != null ? objState.State1 : null)
|
||||
.Include(obj => obj.State).ThenInclude(objState => objState != null ? objState.TFControls : null)
|
||||
.Include(obj => obj.StateHistories).ThenInclude(hist => hist != null ? hist.State1 : null)
|
||||
.ToListAsync(cancel);
|
||||
}
|
||||
@ -52,6 +52,11 @@ public class WFDBContext : DbContext, IUserManagerDbContext
|
||||
.HasForeignKey(control => control.ObjStateId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<PObject>()
|
||||
.HasMany(p => p.StateHistories)
|
||||
.WithOne()
|
||||
.HasForeignKey(hist => hist.ObjectId);
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user