From 1a7dac7af1b61c49777b16f71c2c635fbc69e28c Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Tue, 25 Aug 2020 16:15:27 -0500 Subject: [PATCH] =?UTF-8?q?refactor(directory):=20=E2=99=BB=20include=20ex?= =?UTF-8?q?plicit=20key=20props,=20flip-flop=20self-referencing=20many-to-?= =?UTF-8?q?many?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/FilterLists.sln.DotSettings | 9 +++++---- ...ner.cs => 20200825210326_Initial.Designer.cs} | 14 +++++++------- ...2124_Initial.cs => 20200825210326_Initial.cs} | 0 .../Migrations/QueryDbContextModelSnapshot.cs | 12 ++++++------ .../Persistence/Queries/Entities/Dependent.cs | 16 +++++++--------- .../Persistence/Queries/Entities/FilterList.cs | 1 + .../Queries/Entities/FilterListLanguage.cs | 8 +++----- .../Queries/Entities/FilterListMaintainer.cs | 8 +++----- .../Queries/Entities/FilterListSyntax.cs | 10 ++++------ .../Queries/Entities/FilterListTag.cs | 8 +++----- .../Persistence/Queries/Entities/Fork.cs | 16 +++++++--------- .../Persistence/Queries/Entities/Merge.cs | 16 +++++++--------- .../Queries/Entities/SegmentViewUrl.cs | 8 +++----- .../Queries/Entities/SegmentViewUrlMirror.cs | 6 ++---- .../Queries/Entities/SoftwareSyntax.cs | 8 +++----- 15 files changed, 61 insertions(+), 79 deletions(-) rename services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/{20200825102124_Initial.Designer.cs => 20200825210326_Initial.Designer.cs} (99%) rename services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/{20200825102124_Initial.cs => 20200825210326_Initial.cs} (100%) diff --git a/services/FilterLists.sln.DotSettings b/services/FilterLists.sln.DotSettings index de90d1de6..ade679a6b 100644 --- a/services/FilterLists.sln.DotSettings +++ b/services/FilterLists.sln.DotSettings @@ -1,11 +1,12 @@ - + NEVER False True CHOP_IF_LONG CHOP_IF_LONG CHOP_IF_LONG + True + True + True + True True \ No newline at end of file diff --git a/services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/20200825102124_Initial.Designer.cs b/services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/20200825210326_Initial.Designer.cs similarity index 99% rename from services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/20200825102124_Initial.Designer.cs rename to services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/20200825210326_Initial.Designer.cs index 19e257f34..3ab11f169 100644 --- a/services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/20200825102124_Initial.Designer.cs +++ b/services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/20200825210326_Initial.Designer.cs @@ -10,7 +10,7 @@ namespace FilterLists.Directory.Infrastructure.Migrations.Migrations { [DbContext(typeof(QueryDbContext))] - [Migration("20200825102124_Initial")] + [Migration("20200825210326_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -371,13 +371,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Dependent", b => { b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "DependencyFilterList") - .WithMany("DependencyFilterLists") + .WithMany("DependentFilterLists") .HasForeignKey("DependencyFilterListId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "DependentFilterList") - .WithMany("DependentFilterLists") + .WithMany("DependencyFilterLists") .HasForeignKey("DependentFilterListId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -453,13 +453,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Fork", b => { b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "ForkFilterList") - .WithMany("ForkFilterLists") + .WithMany("UpstreamFilterLists") .HasForeignKey("ForkFilterListId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "UpstreamFilterList") - .WithMany("UpstreamFilterLists") + .WithMany("ForkFilterLists") .HasForeignKey("UpstreamFilterListId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -468,13 +468,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Merge", b => { b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "IncludedInFilterList") - .WithMany("IncludedInFilterLists") + .WithMany("IncludesFilterLists") .HasForeignKey("IncludedInFilterListId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "IncludesFilterList") - .WithMany("IncludesFilterLists") + .WithMany("IncludedInFilterLists") .HasForeignKey("IncludesFilterListId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); diff --git a/services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/20200825102124_Initial.cs b/services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/20200825210326_Initial.cs similarity index 100% rename from services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/20200825102124_Initial.cs rename to services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/20200825210326_Initial.cs diff --git a/services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/QueryDbContextModelSnapshot.cs b/services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/QueryDbContextModelSnapshot.cs index db363785a..22a84cfda 100644 --- a/services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/QueryDbContextModelSnapshot.cs +++ b/services/directory/src/FilterLists.Directory.Infrastructure.Migrations/Migrations/QueryDbContextModelSnapshot.cs @@ -369,13 +369,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Dependent", b => { b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "DependencyFilterList") - .WithMany("DependencyFilterLists") + .WithMany("DependentFilterLists") .HasForeignKey("DependencyFilterListId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "DependentFilterList") - .WithMany("DependentFilterLists") + .WithMany("DependencyFilterLists") .HasForeignKey("DependentFilterListId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -451,13 +451,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Fork", b => { b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "ForkFilterList") - .WithMany("ForkFilterLists") + .WithMany("UpstreamFilterLists") .HasForeignKey("ForkFilterListId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "UpstreamFilterList") - .WithMany("UpstreamFilterLists") + .WithMany("ForkFilterLists") .HasForeignKey("UpstreamFilterListId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -466,13 +466,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Merge", b => { b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "IncludedInFilterList") - .WithMany("IncludedInFilterLists") + .WithMany("IncludesFilterLists") .HasForeignKey("IncludedInFilterListId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "IncludesFilterList") - .WithMany("IncludesFilterLists") + .WithMany("IncludedInFilterLists") .HasForeignKey("IncludesFilterListId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); diff --git a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/Dependent.cs b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/Dependent.cs index 74b0197a4..f12422902 100644 --- a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/Dependent.cs +++ b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/Dependent.cs @@ -8,7 +8,9 @@ namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities [SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")] public class Dependent { + public int DependencyFilterListId { get; private set; } public FilterList DependencyFilterList { get; private set; } = null!; + public int DependentFilterListId { get; private set; } public FilterList DependentFilterList { get; private set; } = null!; } @@ -20,17 +22,13 @@ public virtual void Configure(EntityTypeBuilder builder) builder.ToTable(nameof(Dependent) + "s"); - const string dependencyFilterListId = nameof(Dependent.DependencyFilterList) + "Id"; - const string dependentFilterListId = nameof(Dependent.DependentFilterList) + "Id"; - builder.Property(dependencyFilterListId); - builder.Property(dependentFilterListId); - builder.HasKey(dependencyFilterListId, dependentFilterListId); + builder.HasKey(d => new {d.DependencyFilterListId, d.DependentFilterListId}); builder.HasOne(d => d.DependencyFilterList) - .WithMany(f => f.DependencyFilterLists) - .HasForeignKey(dependencyFilterListId); + .WithMany(fl => fl.DependentFilterLists) + .HasForeignKey(d => d.DependencyFilterListId); builder.HasOne(d => d.DependentFilterList) - .WithMany(f => f.DependentFilterLists) - .HasForeignKey(dependentFilterListId); + .WithMany(fl => fl.DependencyFilterLists) + .HasForeignKey(d => d.DependentFilterListId); } } } \ No newline at end of file diff --git a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterList.cs b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterList.cs index 02fa28b72..8e5da5a5b 100644 --- a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterList.cs +++ b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterList.cs @@ -10,6 +10,7 @@ public class FilterList public int Id { get; private set; } public string Name { get; private set; } = null!; public string? Description { get; private set; } + public int? LicenseId { get; private set; } public License? License { get; private set; } public IReadOnlyCollection FilterListSyntaxes { get; private set; } = new HashSet(); public IReadOnlyCollection FilterListLanguages { get; private set; } = new HashSet(); diff --git a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListLanguage.cs b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListLanguage.cs index c41ae4b75..3c93d6f10 100644 --- a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListLanguage.cs +++ b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListLanguage.cs @@ -8,7 +8,9 @@ namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities [SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")] public class FilterListLanguage { + public int FilterListId { get; private set; } public FilterList FilterList { get; private set; } = null!; + public string LanguageIso6391 { get; private set; } = null!; public Language Language { get; private set; } = null!; } @@ -20,11 +22,7 @@ public virtual void Configure(EntityTypeBuilder builder) builder.ToTable(nameof(FilterListLanguage) + "s"); - const string filterListId = nameof(FilterListLanguage.FilterList) + "Id"; - const string languageId = nameof(Language) + nameof(Language.Iso6391); - builder.Property(filterListId); - builder.Property(languageId); - builder.HasKey(filterListId, languageId); + builder.HasKey(fll => new {fll.FilterListId, fll.LanguageIso6391}); } } } \ No newline at end of file diff --git a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListMaintainer.cs b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListMaintainer.cs index be484e664..b8e865e22 100644 --- a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListMaintainer.cs +++ b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListMaintainer.cs @@ -8,7 +8,9 @@ namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities [SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")] public class FilterListMaintainer { + public int FilterListId { get; private set; } public FilterList FilterList { get; private set; } = null!; + public int MaintainerId { get; private set; } public Maintainer Maintainer { get; private set; } = null!; } @@ -20,11 +22,7 @@ public virtual void Configure(EntityTypeBuilder builder) builder.ToTable(nameof(FilterListMaintainer) + "s"); - const string filterListId = nameof(FilterListMaintainer.FilterList) + "Id"; - const string maintainerId = nameof(FilterListMaintainer.Maintainer) + "Id"; - builder.Property(filterListId); - builder.Property(maintainerId); - builder.HasKey(filterListId, maintainerId); + builder.HasKey(flm => new {flm.FilterListId, flm.MaintainerId}); } } } \ No newline at end of file diff --git a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListSyntax.cs b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListSyntax.cs index 2ebd5c9b6..b7108f391 100644 --- a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListSyntax.cs +++ b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListSyntax.cs @@ -8,7 +8,9 @@ namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities [SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")] public class FilterListSyntax { + public int FilterListId { get; private set; } public FilterList FilterList { get; private set; } = null!; + public int SyntaxId { get; private set; } public Syntax Syntax { get; private set; } = null!; } @@ -17,14 +19,10 @@ internal class FilterListSyntaxTypeConfiguration : IEntityTypeConfiguration builder) { _ = builder ?? throw new ArgumentNullException(nameof(builder)); - + builder.ToTable(nameof(FilterListSyntax) + "es"); - const string filterListId = nameof(FilterListSyntax.FilterList) + "Id"; - const string syntaxId = nameof(FilterListSyntax.Syntax) + "Id"; - builder.Property(filterListId); - builder.Property(syntaxId); - builder.HasKey(filterListId, syntaxId); + builder.HasKey(fls => new {fls.FilterListId, fls.SyntaxId}); } } } \ No newline at end of file diff --git a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListTag.cs b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListTag.cs index 2fc873226..0b92b07ad 100644 --- a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListTag.cs +++ b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/FilterListTag.cs @@ -8,7 +8,9 @@ namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities [SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")] public class FilterListTag { + public int FilterListId { get; private set; } public FilterList FilterList { get; private set; } = null!; + public int TagId { get; private set; } public Tag Tag { get; private set; } = null!; } @@ -20,11 +22,7 @@ public virtual void Configure(EntityTypeBuilder builder) builder.ToTable(nameof(FilterListTag) + "s"); - const string filterListId = nameof(FilterListTag.FilterList) + "Id"; - const string tagId = nameof(FilterListTag.Tag) + "Id"; - builder.Property(filterListId); - builder.Property(tagId); - builder.HasKey(filterListId, tagId); + builder.HasKey(flt => new {flt.FilterListId, flt.TagId}); } } } \ No newline at end of file diff --git a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/Fork.cs b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/Fork.cs index 75961a155..8811be8f0 100644 --- a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/Fork.cs +++ b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/Fork.cs @@ -8,7 +8,9 @@ namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities [SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")] public class Fork { + public int UpstreamFilterListId { get; private set; } public FilterList UpstreamFilterList { get; private set; } = null!; + public int ForkFilterListId { get; private set; } public FilterList ForkFilterList { get; private set; } = null!; } @@ -20,17 +22,13 @@ public virtual void Configure(EntityTypeBuilder builder) builder.ToTable(nameof(Fork) + "s"); - const string upstreamFilterListId = nameof(Fork.UpstreamFilterList) + "Id"; - const string forkFilterListId = nameof(Fork.ForkFilterList) + "Id"; - builder.Property(upstreamFilterListId); - builder.Property(forkFilterListId); - builder.HasKey(upstreamFilterListId, forkFilterListId); + builder.HasKey(f => new {f.UpstreamFilterListId, f.ForkFilterListId}); builder.HasOne(f => f.UpstreamFilterList) - .WithMany(f => f.UpstreamFilterLists) - .HasForeignKey(upstreamFilterListId); + .WithMany(fl => fl.ForkFilterLists) + .HasForeignKey(f => f.UpstreamFilterListId); builder.HasOne(f => f.ForkFilterList) - .WithMany(f => f.ForkFilterLists) - .HasForeignKey(forkFilterListId); + .WithMany(fl => fl.UpstreamFilterLists) + .HasForeignKey(f => f.ForkFilterListId); } } } \ No newline at end of file diff --git a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/Merge.cs b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/Merge.cs index 980f9b83c..69e1b8c21 100644 --- a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/Merge.cs +++ b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/Merge.cs @@ -8,7 +8,9 @@ namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities [SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")] public class Merge { + public int IncludedInFilterListId { get; set; } public FilterList IncludedInFilterList { get; private set; } = null!; + public int IncludesFilterListId { get; set; } public FilterList IncludesFilterList { get; private set; } = null!; } @@ -20,17 +22,13 @@ public virtual void Configure(EntityTypeBuilder builder) builder.ToTable(nameof(Merge) + "s"); - const string includedInFilterListId = nameof(Merge.IncludedInFilterList) + "Id"; - const string includesFilterListId = nameof(Merge.IncludesFilterList) + "Id"; - builder.Property(includedInFilterListId); - builder.Property(includesFilterListId); - builder.HasKey(includedInFilterListId, includesFilterListId); + builder.HasKey(m => new {m.IncludedInFilterListId, m.IncludesFilterListId}); builder.HasOne(m => m.IncludedInFilterList) - .WithMany(f => f.IncludedInFilterLists) - .HasForeignKey(includedInFilterListId); + .WithMany(fl => fl.IncludesFilterLists) + .HasForeignKey(m => m.IncludedInFilterListId); builder.HasOne(m => m.IncludesFilterList) - .WithMany(f => f.IncludesFilterLists) - .HasForeignKey(includesFilterListId); + .WithMany(fl => fl.IncludedInFilterLists) + .HasForeignKey(m => m.IncludesFilterListId); } } } \ No newline at end of file diff --git a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/SegmentViewUrl.cs b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/SegmentViewUrl.cs index 7dd1a7366..54d48fc61 100644 --- a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/SegmentViewUrl.cs +++ b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/SegmentViewUrl.cs @@ -9,6 +9,8 @@ namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities [SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")] public class SegmentViewUrl { + public int Id { get; private set; } + public int FilterListId { get; set; } public FilterList FilterList { get; private set; } = null!; public int Position { get; private set; } public Uri Url { get; private set; } = null!; @@ -23,11 +25,7 @@ public virtual void Configure(EntityTypeBuilder builder) builder.ToTable(nameof(SegmentViewUrl) + "s"); - const string segmentViewUrlId = "Id"; - builder.Property(segmentViewUrlId); - builder.HasKey(segmentViewUrlId); - - builder.HasIndex(nameof(FilterList) + "Id", nameof(SegmentViewUrl.Position)) + builder.HasIndex(s => new {s.FilterListId, s.Position}) .IsUnique(); } } diff --git a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/SegmentViewUrlMirror.cs b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/SegmentViewUrlMirror.cs index df95f7bc5..4ca4ef2e5 100644 --- a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/SegmentViewUrlMirror.cs +++ b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/SegmentViewUrlMirror.cs @@ -8,6 +8,8 @@ namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities [SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")] public class SegmentViewUrlMirror { + public int Id { get; private set; } + public int SegmentViewUrlId { get; private set; } public SegmentViewUrl SegmentViewUrl { get; private set; } = null!; public Uri Url { get; private set; } = null!; } @@ -19,10 +21,6 @@ public virtual void Configure(EntityTypeBuilder builder) _ = builder ?? throw new ArgumentNullException(nameof(builder)); builder.ToTable(nameof(SegmentViewUrlMirror) + "s"); - - const string segmentViewUrlMirrorId = "Id"; - builder.Property(segmentViewUrlMirrorId); - builder.HasKey(segmentViewUrlMirrorId); } } } \ No newline at end of file diff --git a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/SoftwareSyntax.cs b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/SoftwareSyntax.cs index bf22dc9bf..3c7cc5474 100644 --- a/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/SoftwareSyntax.cs +++ b/services/directory/src/FilterLists.Directory.Infrastructure/Persistence/Queries/Entities/SoftwareSyntax.cs @@ -8,7 +8,9 @@ namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities [SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")] public class SoftwareSyntax { + public int SoftwareId { get; private set; } public Software Software { get; private set; } = null!; + public int SyntaxId { get; private set; } public Syntax Syntax { get; private set; } = null!; } @@ -20,11 +22,7 @@ public virtual void Configure(EntityTypeBuilder builder) builder.ToTable(nameof(SoftwareSyntax) + "es"); - const string softwareId = nameof(SoftwareSyntax.Software) + "Id"; - const string syntaxId = nameof(SoftwareSyntax.Syntax) + "Id"; - builder.Property(softwareId); - builder.Property(syntaxId); - builder.HasKey(softwareId, syntaxId); + builder.HasKey(ss => new {ss.SoftwareId, ss.SyntaxId}); } } } \ No newline at end of file