feat: Beziehung zwischen „ObjectState“ und „TfFiles“ hinzufügen

This commit is contained in:
tekh 2025-08-01 16:01:38 +02:00
parent 26300d8653
commit b859391ab1
3 changed files with 9 additions and 1 deletions

View File

@ -83,4 +83,6 @@ public class PObjectState
public virtual State? State1 { get; set; }
public virtual IEnumerable<PControlsTF>? TFControls { get; set; }
public virtual IEnumerable<TfFile>? TfFiles { get; set; }
}

View File

@ -37,6 +37,7 @@ 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)
.Include(obj => obj.State).ThenInclude(objState => objState != null ? objState.TfFiles : null)
.Include(obj => obj.StateHistories!).ThenInclude(hist => hist != null ? hist.State1 : null)
.ToListAsync(cancel);
}

View File

@ -52,6 +52,11 @@ public class WFDBContext : DbContext, IUserManagerDbContext
.HasForeignKey(control => control.ObjStateId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<PObjectState>()
.HasMany(objState => objState.TfFiles)
.WithOne()
.HasForeignKey(file => file.ObjStateId);
modelBuilder.Entity<PObject>()
.HasMany(p => p.StateHistories)
.WithOne()