From 723106e10cff0b7bcd7a33fccda763560eff4573 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Mon, 29 Nov 2021 16:59:07 -0600 Subject: [PATCH] =?UTF-8?q?fix(dir):=20=F0=9F=90=9B=20ICommandContext=20ma?= =?UTF-8?q?ny-to-many=20configs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/CreateList.cs | 10 ++-- .../FilterListTypeConfiguration.cs | 56 ++++++++++++++++--- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/services/Directory/FilterLists.Directory.Application/Commands/CreateList.cs b/services/Directory/FilterLists.Directory.Application/Commands/CreateList.cs index 11d2e395b..ecbe86f0b 100644 --- a/services/Directory/FilterLists.Directory.Application/Commands/CreateList.cs +++ b/services/Directory/FilterLists.Directory.Application/Commands/CreateList.cs @@ -268,23 +268,23 @@ public async Task Handle(Command request, CancellationToken cancellati } if (request.ForkFilterListIds.Any(fid => !relatedFilterLists.Select(f => f.Id).Contains(fid))) { - throw new ArgumentException("One or more ForkFilterListIds not found.", nameof(request.UpstreamFilterListIds)); + throw new ArgumentException("One or more ForkFilterListIds not found.", nameof(request.ForkFilterListIds)); } if (request.IncludedInFilterListIds.Any(fid => !relatedFilterLists.Select(f => f.Id).Contains(fid))) { - throw new ArgumentException("One or more IncludedInFilterListIds not found.", nameof(request.UpstreamFilterListIds)); + throw new ArgumentException("One or more IncludedInFilterListIds not found.", nameof(request.IncludedInFilterListIds)); } if (request.IncludesFilterListIds.Any(fid => !relatedFilterLists.Select(f => f.Id).Contains(fid))) { - throw new ArgumentException("One or more IncludesFilterListIds not found.", nameof(request.UpstreamFilterListIds)); + throw new ArgumentException("One or more IncludesFilterListIds not found.", nameof(request.IncludesFilterListIds)); } if (request.DependencyFilterListIds.Any(fid => !relatedFilterLists.Select(f => f.Id).Contains(fid))) { - throw new ArgumentException("One or more DependencyFilterListIds not found.", nameof(request.UpstreamFilterListIds)); + throw new ArgumentException("One or more DependencyFilterListIds not found.", nameof(request.DependencyFilterListIds)); } if (request.DependentFilterListIds.Any(fid => !relatedFilterLists.Select(f => f.Id).Contains(fid))) { - throw new ArgumentException("One or more DependentFilterListIds not found.", nameof(request.UpstreamFilterListIds)); + throw new ArgumentException("One or more DependentFilterListIds not found.", nameof(request.DependentFilterListIds)); } var filterList = FilterList.CreatePendingApproval( diff --git a/services/Directory/FilterLists.Directory.Infrastructure/Persistence/Commands/EntityTypeConfigurations/FilterListTypeConfiguration.cs b/services/Directory/FilterLists.Directory.Infrastructure/Persistence/Commands/EntityTypeConfigurations/FilterListTypeConfiguration.cs index 9cbee2e19..7ff78e451 100644 --- a/services/Directory/FilterLists.Directory.Infrastructure/Persistence/Commands/EntityTypeConfigurations/FilterListTypeConfiguration.cs +++ b/services/Directory/FilterLists.Directory.Infrastructure/Persistence/Commands/EntityTypeConfigurations/FilterListTypeConfiguration.cs @@ -16,25 +16,67 @@ public virtual void Configure(EntityTypeBuilder builder) builder.HasMany(f => f.Syntaxes) .WithMany(s => s.FilterLists) - .UsingEntity(e => e.ToTable($"{nr.RewriteName(nameof(FilterListSyntax))}es")); + .UsingEntity(e => + { + e.ToTable($"{nr.RewriteName(nameof(FilterListSyntax))}es"); + e.Property(nameof(FilterListSyntax.FilterListId)); + e.Property(nameof(FilterListSyntax.SyntaxId)); + e.HasKey(nameof(FilterListSyntax.FilterListId), nameof(FilterListSyntax.SyntaxId)); + }); builder.HasMany(f => f.Languages) .WithMany(l => l.FilterLists) - .UsingEntity(e => e.ToTable($"{nr.RewriteName(nameof(FilterListLanguage))}s")); + .UsingEntity(e => + { + e.ToTable($"{nr.RewriteName(nameof(FilterListLanguage))}s"); + e.Property(nameof(FilterListLanguage.FilterListId)); + e.Property(nameof(FilterListLanguage.LanguageId)); + e.HasKey(nameof(FilterListLanguage.FilterListId), nameof(FilterListLanguage.LanguageId)); + }); builder.HasMany(f => f.Tags) .WithMany(t => t.FilterLists) - .UsingEntity(e => e.ToTable($"{nr.RewriteName(nameof(FilterListTag))}s")); + .UsingEntity(e => + { + e.ToTable($"{nr.RewriteName(nameof(FilterListTag))}s"); + e.Property(nameof(FilterListTag.FilterListId)); + e.Property(nameof(FilterListTag.TagId)); + e.HasKey(nameof(FilterListTag.FilterListId), nameof(FilterListTag.TagId)); + }); builder.HasMany(f => f.Maintainers) .WithMany(m => m.FilterLists) - .UsingEntity(e => e.ToTable($"{nr.RewriteName(nameof(FilterListMaintainer))}s")); + .UsingEntity(e => + { + e.ToTable($"{nr.RewriteName(nameof(FilterListMaintainer))}s"); + e.Property(nameof(FilterListMaintainer.FilterListId)); + e.Property(nameof(FilterListMaintainer.MaintainerId)); + e.HasKey(nameof(FilterListMaintainer.FilterListId), nameof(FilterListMaintainer.MaintainerId)); + }); builder.HasMany(f => f.UpstreamFilterLists) .WithMany(f => f.ForkFilterLists) - .UsingEntity(e => e.ToTable($"{nr.RewriteName(nameof(Fork))}s")); + .UsingEntity(e => + { + e.ToTable($"{nr.RewriteName(nameof(Fork))}s"); + e.Property(nameof(Fork.UpstreamFilterListId)); + e.Property(nameof(Fork.ForkFilterListId)); + e.HasKey(nameof(Fork.UpstreamFilterListId), nameof(Fork.ForkFilterListId)); + }); builder.HasMany(f => f.IncludedInFilterLists) .WithMany(f => f.IncludesFilterLists) - .UsingEntity(e => e.ToTable($"{nr.RewriteName(nameof(Merge))}s")); + .UsingEntity(e => + { + e.ToTable($"{nr.RewriteName(nameof(Merge))}s"); + e.Property(nameof(Merge.IncludedInFilterListId)); + e.Property(nameof(Merge.IncludesFilterListId)); + e.HasKey(nameof(Merge.IncludedInFilterListId), nameof(Merge.IncludesFilterListId)); + }); builder.HasMany(f => f.DependencyFilterLists) .WithMany(f => f.DependentFilterLists) - .UsingEntity(e => e.ToTable($"{nr.RewriteName(nameof(Dependent))}s")); + .UsingEntity(e => + { + e.ToTable($"{nr.RewriteName(nameof(Dependent))}s"); + e.Property(nameof(Dependent.DependencyFilterListId)); + e.Property(nameof(Dependent.DependentFilterListId)); + e.HasKey(nameof(Dependent.DependencyFilterListId), nameof(Dependent.DependentFilterListId)); + }); builder.HasMany(f => f.Changes) .WithOne() .HasForeignKey(nameof(Change.FilterListId));