diff --git a/OpenNest.Training/Data/TrainingAngleResult.cs b/OpenNest.Training/Data/TrainingAngleResult.cs new file mode 100644 index 0000000..b01a0ce --- /dev/null +++ b/OpenNest.Training/Data/TrainingAngleResult.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace OpenNest.Training.Data +{ + [Table("AngleResults")] + public class TrainingAngleResult + { + [Key] + public long Id { get; set; } + + public long RunId { get; set; } + public double AngleDeg { get; set; } + public string Direction { get; set; } + public int PartCount { get; set; } + + [ForeignKey(nameof(RunId))] + public TrainingRun Run { get; set; } + } +} diff --git a/OpenNest.Training/Data/TrainingDbContext.cs b/OpenNest.Training/Data/TrainingDbContext.cs index 12bc817..5ffcaaa 100644 --- a/OpenNest.Training/Data/TrainingDbContext.cs +++ b/OpenNest.Training/Data/TrainingDbContext.cs @@ -6,6 +6,7 @@ namespace OpenNest.Training.Data { public DbSet Parts { get; set; } public DbSet Runs { get; set; } + public DbSet AngleResults { get; set; } private readonly string _dbPath; @@ -33,6 +34,14 @@ namespace OpenNest.Training.Data .WithMany(p => p.Runs) .HasForeignKey(r => r.PartId); }); + + modelBuilder.Entity(e => + { + e.HasIndex(a => a.RunId).HasDatabaseName("idx_angleresults_runid"); + e.HasOne(a => a.Run) + .WithMany(r => r.AngleResults) + .HasForeignKey(a => a.RunId); + }); } } } diff --git a/OpenNest.Training/Data/TrainingRun.cs b/OpenNest.Training/Data/TrainingRun.cs index a8ae46a..c968ff4 100644 --- a/OpenNest.Training/Data/TrainingRun.cs +++ b/OpenNest.Training/Data/TrainingRun.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; @@ -18,8 +19,18 @@ namespace OpenNest.Training.Data public long TimeMs { get; set; } public string LayoutData { get; set; } public string FilePath { get; set; } + public string WinnerEngine { get; set; } = ""; + public long WinnerTimeMs { get; set; } + public string RunnerUpEngine { get; set; } = ""; + public int RunnerUpPartCount { get; set; } + public long RunnerUpTimeMs { get; set; } + public string ThirdPlaceEngine { get; set; } = ""; + public int ThirdPlacePartCount { get; set; } + public long ThirdPlaceTimeMs { get; set; } [ForeignKey(nameof(PartId))] public TrainingPart Part { get; set; } + + public List AngleResults { get; set; } = new(); } }