mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
refactor(directory): ♻ use shaddow Id props, mv mappings to entity files
This commit is contained in:
parent
bbd1f46347
commit
d73bbe2e87
29 changed files with 354 additions and 302 deletions
|
|
@ -1,7 +0,0 @@
|
|||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Contracts
|
||||
{
|
||||
internal interface IHaveSurrogateKey
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,33 @@
|
|||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class Dependent
|
||||
{
|
||||
public FilterList DependencyFilterList { get; private set; } = null!;
|
||||
public FilterList DependentFilterList { get; private set; } = null!;
|
||||
}
|
||||
|
||||
internal class DependentTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : Dependent
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string dependencyFilterListId = nameof(Dependent.DependencyFilterList) + "Id";
|
||||
const string dependentFilterListId = nameof(Dependent.DependentFilterList) + "Id";
|
||||
builder.Property<int>(dependencyFilterListId);
|
||||
builder.Property<int>(dependentFilterListId);
|
||||
builder.HasKey(dependencyFilterListId, dependentFilterListId);
|
||||
builder.HasOne(d => d.DependencyFilterList)
|
||||
.WithMany(f => (IEnumerable<TEntity>)f.DependencyFilterLists)
|
||||
.HasForeignKey(dependencyFilterListId);
|
||||
builder.HasOne(d => d.DependentFilterList)
|
||||
.WithMany(f => (IEnumerable<TEntity>)f.DependentFilterLists)
|
||||
.HasForeignKey(dependentFilterListId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Contracts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class FilterList : IHaveSurrogateKey
|
||||
public class FilterList
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
public string Name { get; } = null!;
|
||||
public string? Description { get; private set; }
|
||||
public License? License { get; private set; }
|
||||
public ICollection<FilterListSyntax> FilterListSyntaxes { get; private set; } = new HashSet<FilterListSyntax>();
|
||||
public ICollection<FilterListLanguage> FilterListLanguages { get; private set; } = new HashSet<FilterListLanguage>();
|
||||
public ICollection<FilterListTag> FilterListTags { get; private set; } = new HashSet<FilterListTag>();
|
||||
public Uri ViewUrl { get; private set; } = null!;
|
||||
public ICollection<ViewUrlPartial> ViewUrlPartials { get; private set; } = new HashSet<ViewUrlPartial>();
|
||||
public ICollection<ViewUrlMirror> ViewUrlMirrors { get; private set; } = new HashSet<ViewUrlMirror>();
|
||||
public ICollection<FilterListSyntax> FilterListSyntaxes { get; } = new HashSet<FilterListSyntax>();
|
||||
public ICollection<FilterListLanguage> FilterListLanguages { get; } = new HashSet<FilterListLanguage>();
|
||||
public ICollection<FilterListTag> FilterListTags { get; } = new HashSet<FilterListTag>();
|
||||
public Uri ViewUrl { get; } = null!;
|
||||
public ICollection<ViewUrlPartial> ViewUrlPartials { get; } = new HashSet<ViewUrlPartial>();
|
||||
public ICollection<ViewUrlMirror> ViewUrlMirrors { get; } = new HashSet<ViewUrlMirror>();
|
||||
public Uri? HomeUrl { get; private set; }
|
||||
public Uri? OnionUrl { get; private set; }
|
||||
public Uri? PolicyUrl { get; private set; }
|
||||
|
|
@ -25,12 +25,24 @@ public class FilterList : IHaveSurrogateKey
|
|||
public Uri? ChatUrl { get; private set; }
|
||||
public string? EmailAddress { get; private set; }
|
||||
public Uri? DonateUrl { get; private set; }
|
||||
public ICollection<FilterListMaintainer> FilterListMaintainers { get; private set; } = new HashSet<FilterListMaintainer>();
|
||||
public ICollection<Fork> UpstreamFilterLists { get; private set; } = new HashSet<Fork>();
|
||||
public ICollection<Fork> ForkFilterLists { get; private set; } = new HashSet<Fork>();
|
||||
public ICollection<Merge> IncludedInFilterLists { get; private set; } = new HashSet<Merge>();
|
||||
public ICollection<Merge> IncludesFilterLists { get; private set; } = new HashSet<Merge>();
|
||||
public ICollection<Dependent> DependencyFilterLists { get; private set; } = new HashSet<Dependent>();
|
||||
public ICollection<Dependent> DependentFilterLists { get; private set; } = new HashSet<Dependent>();
|
||||
public ICollection<FilterListMaintainer> FilterListMaintainers { get; } = new HashSet<FilterListMaintainer>();
|
||||
public ICollection<Fork> UpstreamFilterLists { get; } = new HashSet<Fork>();
|
||||
public ICollection<Fork> ForkFilterLists { get; } = new HashSet<Fork>();
|
||||
public ICollection<Merge> IncludedInFilterLists { get; } = new HashSet<Merge>();
|
||||
public ICollection<Merge> IncludesFilterLists { get; } = new HashSet<Merge>();
|
||||
public ICollection<Dependent> DependencyFilterLists { get; } = new HashSet<Dependent>();
|
||||
public ICollection<Dependent> DependentFilterLists { get; } = new HashSet<Dependent>();
|
||||
}
|
||||
|
||||
internal class FilterListTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : FilterList
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string filterListId = "Id";
|
||||
builder.Property<int>(filterListId);
|
||||
builder.HasKey(filterListId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,27 @@
|
|||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class FilterListLanguage
|
||||
{
|
||||
public FilterList FilterList { get; private set; } = null!;
|
||||
public Language Language { get; private set; } = null!;
|
||||
}
|
||||
|
||||
internal class FilterListLanguageTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : FilterListLanguage
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string filterListId = nameof(FilterListLanguage.FilterList) + "Id";
|
||||
const string languageId = nameof(FilterListLanguage.Language) + "Id";
|
||||
builder.Property<int>(filterListId);
|
||||
builder.Property<int>(languageId);
|
||||
builder.HasKey(filterListId, languageId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,27 @@
|
|||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class FilterListMaintainer
|
||||
{
|
||||
public FilterList FilterList { get; private set; } = null!;
|
||||
public Maintainer Maintainer { get; private set; } = null!;
|
||||
}
|
||||
|
||||
internal class FilterListMaintainerTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : FilterListMaintainer
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string filterListId = nameof(FilterListMaintainer.FilterList) + "Id";
|
||||
const string maintainerId = nameof(FilterListMaintainer.Maintainer) + "Id";
|
||||
builder.Property<int>(filterListId);
|
||||
builder.Property<int>(maintainerId);
|
||||
builder.HasKey(filterListId, maintainerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,27 @@
|
|||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class FilterListSyntax
|
||||
{
|
||||
public FilterList FilterList { get; private set; } = null!;
|
||||
public Syntax Syntax { get; private set; } = null!;
|
||||
}
|
||||
|
||||
internal class FilterListSyntaxTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : FilterListSyntax
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string filterListId = nameof(FilterListSyntax.FilterList) + "Id";
|
||||
const string syntaxId = nameof(FilterListSyntax.Syntax) + "Id";
|
||||
builder.Property<int>(filterListId);
|
||||
builder.Property<int>(syntaxId);
|
||||
builder.HasKey(filterListId, syntaxId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,27 @@
|
|||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class FilterListTag
|
||||
{
|
||||
public FilterList FilterList { get; private set; } = null!;
|
||||
public Tag Tag { get; private set; } = null!;
|
||||
}
|
||||
|
||||
internal class FilterListTagTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : FilterListTag
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string filterListId = nameof(FilterListTag.FilterList) + "Id";
|
||||
const string tagId = nameof(FilterListTag.Tag) + "Id";
|
||||
builder.Property<int>(filterListId);
|
||||
builder.Property<int>(tagId);
|
||||
builder.HasKey(filterListId, tagId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,33 @@
|
|||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class Fork
|
||||
{
|
||||
public FilterList UpstreamFilterList { get; private set; } = null!;
|
||||
public FilterList ForkFilterList { get; private set; } = null!;
|
||||
}
|
||||
|
||||
internal class ForkTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : Fork
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string upstreamFilterListId = nameof(Fork.UpstreamFilterList) + "Id";
|
||||
const string forkFilterListId = nameof(Fork.ForkFilterList) + "Id";
|
||||
builder.Property<int>(upstreamFilterListId);
|
||||
builder.Property<int>(forkFilterListId);
|
||||
builder.HasKey(upstreamFilterListId, forkFilterListId);
|
||||
builder.HasOne(f => f.UpstreamFilterList)
|
||||
.WithMany(f => (IEnumerable<TEntity>)f.UpstreamFilterLists)
|
||||
.HasForeignKey(upstreamFilterListId);
|
||||
builder.HasOne(f => f.ForkFilterList)
|
||||
.WithMany(f => (IEnumerable<TEntity>)f.ForkFilterLists)
|
||||
.HasForeignKey(forkFilterListId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,25 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class Language
|
||||
{
|
||||
public string Iso6391 { get; private set; } = null!;
|
||||
public string Name { get; private set; } = null!;
|
||||
public ICollection<FilterListLanguage> FilterListLanguages { get; private set; } = new HashSet<FilterListLanguage>();
|
||||
public string Iso6391 { get; } = null!;
|
||||
public string Name { get; } = null!;
|
||||
public ICollection<FilterListLanguage> FilterListLanguages { get; } = new HashSet<FilterListLanguage>();
|
||||
}
|
||||
|
||||
internal class LanguageTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : Language
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
builder.HasKey(l => l.Iso6391);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Contracts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class License : IHaveSurrogateKey
|
||||
public class License
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
public string Name { get; } = null!;
|
||||
public string? GitHubKey { get; private set; }
|
||||
public Uri? Url { get; private set; }
|
||||
public ICollection<FilterList> FilterLists { get; private set; } = new HashSet<FilterList>();
|
||||
public ICollection<FilterList> FilterLists { get; } = new HashSet<FilterList>();
|
||||
}
|
||||
|
||||
internal class LicenseTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : License
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string licenseId = "Id";
|
||||
builder.Property<int>(licenseId);
|
||||
builder.HasKey(licenseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Contracts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class Maintainer : IHaveSurrogateKey
|
||||
public class Maintainer
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
public string Name { get; } = null!;
|
||||
public Uri? Url { get; private set; }
|
||||
public string? EmailAddress { get; private set; }
|
||||
public string? TwitterHandle { get; private set; }
|
||||
public ICollection<FilterListMaintainer> FilterListMaintainers { get; private set; } = new HashSet<FilterListMaintainer>();
|
||||
public ICollection<FilterListMaintainer> FilterListMaintainers { get; } = new HashSet<FilterListMaintainer>();
|
||||
}
|
||||
|
||||
internal class MaintainerTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : Maintainer
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string maintainerId = "Id";
|
||||
builder.Property<int>(maintainerId);
|
||||
builder.HasKey(maintainerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,33 @@
|
|||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class Merge
|
||||
{
|
||||
public FilterList IncludedInFilterList { get; private set; } = null!;
|
||||
public FilterList IncludesFilterList { get; private set; } = null!;
|
||||
}
|
||||
|
||||
internal class MergeTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : Merge
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string includedInFilterListId = nameof(Merge.IncludedInFilterList) + "Id";
|
||||
const string includesFilterListId = nameof(Merge.IncludesFilterList) + "Id";
|
||||
builder.Property<int>(includedInFilterListId);
|
||||
builder.Property<int>(includesFilterListId);
|
||||
builder.HasKey(includedInFilterListId, includesFilterListId);
|
||||
builder.HasOne(m => m.IncludedInFilterList)
|
||||
.WithMany(f => (IEnumerable<TEntity>)f.IncludedInFilterLists)
|
||||
.HasForeignKey(includedInFilterListId);
|
||||
builder.HasOne(m => m.IncludesFilterList)
|
||||
.WithMany(f => (IEnumerable<TEntity>)f.IncludesFilterLists)
|
||||
.HasForeignKey(includesFilterListId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Contracts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class Software : IHaveSurrogateKey
|
||||
public class Software
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
public string Name { get; } = null!;
|
||||
public string? Description { get; private set; }
|
||||
public Uri? HomeUrl { get; private set; }
|
||||
public Uri? DownloadUrl { get; private set; }
|
||||
public bool SupportsAbpUrlScheme { get; private set; }
|
||||
public ICollection<SoftwareSyntax> SoftwareSyntaxes { get; private set; } = new HashSet<SoftwareSyntax>();
|
||||
public ICollection<SoftwareSyntax> SoftwareSyntaxes { get; } = new HashSet<SoftwareSyntax>();
|
||||
}
|
||||
|
||||
internal class SoftwareTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : Software
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string softwareId = "Id";
|
||||
builder.Property<int>(softwareId);
|
||||
builder.HasKey(softwareId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,27 @@
|
|||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class SoftwareSyntax
|
||||
{
|
||||
public Software Software { get; private set; } = null!;
|
||||
public Syntax Syntax { get; private set; } = null!;
|
||||
}
|
||||
|
||||
internal class SoftwareSyntaxTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : SoftwareSyntax
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string softwareId = nameof(SoftwareSyntax.Software) + "Id";
|
||||
const string syntaxId = nameof(SoftwareSyntax.Syntax) + "Id";
|
||||
builder.Property<int>(softwareId);
|
||||
builder.Property<int>(syntaxId);
|
||||
builder.HasKey(softwareId, syntaxId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Contracts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class Syntax : IHaveSurrogateKey
|
||||
public class Syntax
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
public string Name { get; } = null!;
|
||||
public string? Description { get; private set; }
|
||||
public Uri? Url { get; private set; }
|
||||
public ICollection<FilterListSyntax> FilterListSyntaxes { get; private set; } = new HashSet<FilterListSyntax>();
|
||||
public ICollection<SoftwareSyntax> SoftwareSyntaxes { get; private set; } = new HashSet<SoftwareSyntax>();
|
||||
public ICollection<FilterListSyntax> FilterListSyntaxes { get; } = new HashSet<FilterListSyntax>();
|
||||
public ICollection<SoftwareSyntax> SoftwareSyntaxes { get; } = new HashSet<SoftwareSyntax>();
|
||||
}
|
||||
|
||||
internal class SyntaxTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : Syntax
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string syntaxId = "Id";
|
||||
builder.Property<int>(syntaxId);
|
||||
builder.HasKey(syntaxId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,26 @@
|
|||
using System.Collections.Generic;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Contracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class Tag : IHaveSurrogateKey
|
||||
public class Tag
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
public string Name { get; } = null!;
|
||||
public string? Description { get; private set; }
|
||||
public ICollection<FilterListTag> FilterListTags { get; private set; } = new HashSet<FilterListTag>();
|
||||
public ICollection<FilterListTag> FilterListTags { get; } = new HashSet<FilterListTag>();
|
||||
}
|
||||
|
||||
internal class TagTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : Tag
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string tagId = "Id";
|
||||
builder.Property<int>(tagId);
|
||||
builder.HasKey(tagId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,25 @@
|
|||
using System;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Contracts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class ViewUrlMirror : IHaveSurrogateKey
|
||||
public class ViewUrlMirror
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public FilterList FilterList { get; private set; } = null!;
|
||||
public Uri Url { get; private set; } = null!;
|
||||
public FilterList FilterList { get; } = null!;
|
||||
public Uri Url { get; } = null!;
|
||||
}
|
||||
|
||||
internal class ViewUrlMirrorTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : ViewUrlMirror
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string viewUrlMirrorId = "Id";
|
||||
builder.Property<int>(viewUrlMirrorId);
|
||||
builder.HasKey(viewUrlMirrorId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
|
|
@ -6,6 +8,19 @@ public class ViewUrlPartial
|
|||
{
|
||||
public FilterList FilterList { get; private set; } = null!;
|
||||
public int Position { get; private set; }
|
||||
public Uri Url { get; private set; } = null!;
|
||||
public Uri Url { get; } = null!;
|
||||
}
|
||||
|
||||
internal class ViewUrlPartialTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : ViewUrlPartial
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string filterListId = nameof(ViewUrlPartial.FilterList) + "Id";
|
||||
builder.Property<int>(filterListId);
|
||||
builder.HasKey(filterListId, nameof(ViewUrlPartial.Position));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Mappings;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Facade
|
||||
|
|
@ -40,14 +39,21 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|||
|
||||
// TODO: rm explicit below once ApplyConfigurationsFromAssembly() works properly
|
||||
modelBuilder.ApplyConfiguration(new DependentTypeConfiguration<Dependent>());
|
||||
modelBuilder.ApplyConfiguration(new FilterListTypeConfiguration<FilterList>());
|
||||
modelBuilder.ApplyConfiguration(new FilterListLanguageTypeConfiguration<FilterListLanguage>());
|
||||
modelBuilder.ApplyConfiguration(new FilterListMaintainerTypeConfiguration<FilterListMaintainer>());
|
||||
modelBuilder.ApplyConfiguration(new FilterListSyntaxTypeConfiguration<FilterListSyntax>());
|
||||
modelBuilder.ApplyConfiguration(new FilterListTagTypeConfiguration<FilterListTag>());
|
||||
modelBuilder.ApplyConfiguration(new ForkTypeConfiguration<Fork>());
|
||||
modelBuilder.ApplyConfiguration(new LanguageTypeConfiguration<Language>());
|
||||
modelBuilder.ApplyConfiguration(new LicenseTypeConfiguration<License>());
|
||||
modelBuilder.ApplyConfiguration(new MaintainerTypeConfiguration<Maintainer>());
|
||||
modelBuilder.ApplyConfiguration(new MergeTypeConfiguration<Merge>());
|
||||
modelBuilder.ApplyConfiguration(new SoftwareTypeConfiguration<Software>());
|
||||
modelBuilder.ApplyConfiguration(new SoftwareSyntaxTypeConfiguration<SoftwareSyntax>());
|
||||
modelBuilder.ApplyConfiguration(new SyntaxTypeConfiguration<Syntax>());
|
||||
modelBuilder.ApplyConfiguration(new TagTypeConfiguration<Tag>());
|
||||
modelBuilder.ApplyConfiguration(new ViewUrlMirrorTypeConfiguration<ViewUrlMirror>());
|
||||
modelBuilder.ApplyConfiguration(new ViewUrlPartialTypeConfiguration<ViewUrlPartial>());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Mappings
|
||||
{
|
||||
internal class DependentTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : Dependent
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string dependencyFilterListId = nameof(Dependent.DependencyFilterList) + "Id";
|
||||
const string dependentFilterListId = nameof(Dependent.DependentFilterList) + "Id";
|
||||
builder.Property<int>(dependencyFilterListId);
|
||||
builder.Property<int>(dependentFilterListId);
|
||||
builder.HasKey(dependencyFilterListId, dependentFilterListId);
|
||||
builder.HasOne(d => d.DependencyFilterList)
|
||||
.WithMany(f => (IEnumerable<TEntity>)f.DependencyFilterLists)
|
||||
.HasForeignKey(dependencyFilterListId);
|
||||
builder.HasOne(d => d.DependentFilterList)
|
||||
.WithMany(f => (IEnumerable<TEntity>)f.DependentFilterLists)
|
||||
.HasForeignKey(dependentFilterListId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
using System;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Mappings
|
||||
{
|
||||
internal class FilterListLanguageTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : FilterListLanguage
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string filterListId = nameof(FilterListLanguage.FilterList) + "Id";
|
||||
const string languageId = nameof(FilterListLanguage.Language) + "Id";
|
||||
builder.Property<int>(filterListId);
|
||||
builder.Property<int>(languageId);
|
||||
builder.HasKey(filterListId, languageId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
using System;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Mappings
|
||||
{
|
||||
internal class FilterListMaintainerTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : FilterListMaintainer
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string filterListId = nameof(FilterListMaintainer.FilterList) + "Id";
|
||||
const string maintainerId = nameof(FilterListMaintainer.Maintainer) + "Id";
|
||||
builder.Property<int>(filterListId);
|
||||
builder.Property<int>(maintainerId);
|
||||
builder.HasKey(filterListId, maintainerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
using System;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Mappings
|
||||
{
|
||||
internal class FilterListSyntaxTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : FilterListSyntax
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string filterListId = nameof(FilterListSyntax.FilterList) + "Id";
|
||||
const string syntaxId = nameof(FilterListSyntax.Syntax) + "Id";
|
||||
builder.Property<int>(filterListId);
|
||||
builder.Property<int>(syntaxId);
|
||||
builder.HasKey(filterListId, syntaxId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
using System;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Mappings
|
||||
{
|
||||
internal class FilterListTagTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : FilterListTag
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string filterListId = nameof(FilterListTag.FilterList) + "Id";
|
||||
const string tagId = nameof(FilterListTag.Tag) + "Id";
|
||||
builder.Property<int>(filterListId);
|
||||
builder.Property<int>(tagId);
|
||||
builder.HasKey(filterListId, tagId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Mappings
|
||||
{
|
||||
internal class ForkTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : Fork
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string upstreamFilterListId = nameof(Fork.UpstreamFilterList) + "Id";
|
||||
const string forkFilterListId = nameof(Fork.ForkFilterList) + "Id";
|
||||
builder.Property<int>(upstreamFilterListId);
|
||||
builder.Property<int>(forkFilterListId);
|
||||
builder.HasKey(upstreamFilterListId, forkFilterListId);
|
||||
builder.HasOne(f => f.UpstreamFilterList)
|
||||
.WithMany(f => (IEnumerable<TEntity>)f.UpstreamFilterLists)
|
||||
.HasForeignKey(upstreamFilterListId);
|
||||
builder.HasOne(f => f.ForkFilterList)
|
||||
.WithMany(f => (IEnumerable<TEntity>)f.ForkFilterLists)
|
||||
.HasForeignKey(forkFilterListId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
using System;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Mappings
|
||||
{
|
||||
internal class LanguageTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : Language
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
builder.HasKey(l => l.Iso6391);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Mappings
|
||||
{
|
||||
internal class MergeTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : Merge
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string includedInFilterListId = nameof(Merge.IncludedInFilterList) + "Id";
|
||||
const string includesFilterListId = nameof(Merge.IncludesFilterList) + "Id";
|
||||
builder.Property<int>(includedInFilterListId);
|
||||
builder.Property<int>(includesFilterListId);
|
||||
builder.HasKey(includedInFilterListId, includesFilterListId);
|
||||
builder.HasOne(m => m.IncludedInFilterList)
|
||||
.WithMany(f => (IEnumerable<TEntity>)f.IncludedInFilterLists)
|
||||
.HasForeignKey(includedInFilterListId);
|
||||
builder.HasOne(m => m.IncludesFilterList)
|
||||
.WithMany(f => (IEnumerable<TEntity>)f.IncludesFilterLists)
|
||||
.HasForeignKey(includesFilterListId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
using System;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Mappings
|
||||
{
|
||||
internal class SoftwareSyntaxTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : SoftwareSyntax
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string softwareId = nameof(SoftwareSyntax.Software) + "Id";
|
||||
const string syntaxId = nameof(SoftwareSyntax.Syntax) + "Id";
|
||||
builder.Property<int>(softwareId);
|
||||
builder.Property<int>(syntaxId);
|
||||
builder.HasKey(softwareId, syntaxId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
using System;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Mappings
|
||||
{
|
||||
internal class ViewUrlPartialTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity>
|
||||
where TEntity : ViewUrlPartial
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
const string filterListId = nameof(ViewUrlPartial.FilterList) + "Id";
|
||||
builder.Property<int>(filterListId);
|
||||
builder.HasKey(filterListId, nameof(ViewUrlPartial.Position));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue