Example #1
0
    public virtual void Configure(EntityTypeBuilder <Change> builder)
    {
        // TODO: register and resolve INameRewriter
        var nr = new SnakeCaseNameRewriter(CultureInfo.InvariantCulture);

        builder.ToTable($"{nr.RewriteName(nameof(Change))}s");
        builder.HasDiscriminator <AggregateType>(nr.RewriteName(nameof(Queries.Entities.Change.AggregateType)))
        .HasValue <FilterListChange>(AggregateType.FilterList);
    }
Example #2
0
    public override void Configure(EntityTypeBuilder <FilterList> builder)
    {
        // TODO: register and resolve INameRewriter
        var nr = new SnakeCaseNameRewriter(CultureInfo.InvariantCulture);

        builder.HasIndex(f => f.Name)
        .IsUnique();
        builder.Property(f => f.LicenseId)
        .HasDefaultValue(5);
        builder.HasOne(f => f.License)
        .WithMany(l => l.FilterLists)
        .OnDelete(DeleteBehavior.Restrict);
        builder.OwnsMany(
            f => f.ViewUrls,
            b =>
        {
            b.ToTable($"{nr.RewriteName(nameof(FilterListViewUrl))}s");
            b.Property(u => u.Id)
            .UseHiLo($"EntityFrameworkHiLoSequence-{nameof(FilterListViewUrl)}");
            b.Property(u => u.SegmentNumber)
            .HasDefaultValue(1);
            b.Property(u => u.Primariness)
            .HasDefaultValue(1);
            b.HasIndex(u => new { u.FilterListId, u.SegmentNumber, u.Primariness })
            .IsUnique();
            b.HasDataJsonFile <FilterListViewUrl>();
        });
        builder.HasDataJsonFileEntityRequiringApproval <FilterList>();
        base.Configure(builder);
    }
Example #3
0
    public virtual void Configure(EntityTypeBuilder <FilterListSyntax> builder)
    {
        // TODO: register and resolve INameRewriter
        var nr = new SnakeCaseNameRewriter(CultureInfo.InvariantCulture);

        builder.ToTable($"{nr.RewriteName(nameof(FilterListSyntax))}es");
        builder.HasKey(fls => new { fls.FilterListId, fls.SyntaxId });
        builder.HasQueryFilter(fls => fls.FilterList.IsApproved && fls.Syntax.IsApproved);
        builder.HasDataJsonFile <FilterListSyntax>();
    }
Example #4
0
    public virtual void Configure(EntityTypeBuilder <SoftwareSyntax> builder)
    {
        // TODO: register and resolve INameRewriter
        var nr = new SnakeCaseNameRewriter(CultureInfo.InvariantCulture);

        builder.ToTable($"{nr.RewriteName(nameof(SoftwareSyntax))}es");
        builder.HasKey(ss => new { ss.SoftwareId, ss.SyntaxId });
        builder.HasQueryFilter(ss => ss.Software.IsApproved && ss.Syntax.IsApproved);
        builder.HasDataJsonFile <SoftwareSyntax>();
    }
Example #5
0
    public virtual void Configure(EntityTypeBuilder <Merge> builder)
    {
        // TODO: register and resolve INameRewriter
        var nr = new SnakeCaseNameRewriter(CultureInfo.InvariantCulture);

        builder.ToTable($"{nr.RewriteName(nameof(Merge))}s");
        builder.HasKey(m => new { m.IncludedInFilterListId, m.IncludesFilterListId });
        builder.HasOne(m => m.IncludedInFilterList)
        .WithMany(fl => fl.IncludesFilterLists)
        .HasForeignKey(m => m.IncludedInFilterListId)
        .HasConstraintName("fk_merges_filter_lists_included_in_filter_list_id");
        builder.HasOne(m => m.IncludesFilterList)
        .WithMany(fl => fl.IncludedInFilterLists)
        .HasForeignKey(m => m.IncludesFilterListId)
        .HasConstraintName("fk_merges_filter_lists_includes_filter_list_id");
        builder.HasQueryFilter(m => m.IncludedInFilterList.IsApproved && m.IncludesFilterList.IsApproved);
        builder.HasDataJsonFile <Merge>();
    }
Example #6
0
    public virtual void Configure(EntityTypeBuilder <Dependent> builder)
    {
        // TODO: register and resolve INameRewriter
        var nr = new SnakeCaseNameRewriter(CultureInfo.InvariantCulture);

        builder.ToTable($"{nr.RewriteName(nameof(Dependent))}s");
        builder.HasKey(d => new { d.DependencyFilterListId, d.DependentFilterListId });
        builder.HasOne(d => d.DependencyFilterList)
        .WithMany(fl => fl.DependentFilterLists)
        .HasForeignKey(d => d.DependencyFilterListId)
        .HasConstraintName("fk_dependents_filter_lists_dependency_filter_list_id");
        builder.HasOne(d => d.DependentFilterList)
        .WithMany(fl => fl.DependencyFilterLists)
        .HasForeignKey(d => d.DependentFilterListId)
        .HasConstraintName("fk_dependents_filter_lists_dependent_filter_list_id");
        builder.HasQueryFilter(d => d.DependencyFilterList.IsApproved && d.DependentFilterList.IsApproved);
        builder.HasDataJsonFile <Dependent>();
    }
Example #7
0
    public virtual void Configure(EntityTypeBuilder <Fork> builder)
    {
        // TODO: register and resolve INameRewriter
        var nr = new SnakeCaseNameRewriter(CultureInfo.InvariantCulture);

        builder.ToTable($"{nr.RewriteName(nameof(Fork))}s");
        builder.HasKey(f => new { f.UpstreamFilterListId, f.ForkFilterListId });
        builder.HasOne(f => f.UpstreamFilterList)
        .WithMany(fl => fl.ForkFilterLists)
        .HasForeignKey(f => f.UpstreamFilterListId)
        .HasConstraintName("fk_forks_filter_lists_upstream_filter_list_id");
        builder.HasOne(f => f.ForkFilterList)
        .WithMany(fl => fl.UpstreamFilterLists)
        .HasForeignKey(f => f.ForkFilterListId)
        .HasConstraintName("fk_forks_filter_lists_fork_filter_list_id");
        builder.HasQueryFilter(f => f.UpstreamFilterList.IsApproved && f.ForkFilterList.IsApproved);
        builder.HasDataJsonFile <Fork>();
    }
Example #8
0
    public virtual void Configure(EntityTypeBuilder <FilterList> builder)
    {
        // TODO: register and resolve INameRewriter
        var nr = new SnakeCaseNameRewriter(CultureInfo.InvariantCulture);

        builder.HasMany(f => f.Syntaxes)
        .WithMany(s => s.FilterLists)
        .UsingEntity(
            nameof(FilterListSyntax),
            e =>
        {
            e.ToTable($"{nr.RewriteName(nameof(FilterListSyntax))}es");
            e.Property <long>(nameof(FilterListSyntax.FilterListId));
            e.Property <long>(nameof(FilterListSyntax.SyntaxId));
            e.HasKey(nameof(FilterListSyntax.FilterListId), nameof(FilterListSyntax.SyntaxId));
        });
        builder.HasMany(f => f.Languages)
        .WithMany(l => l.FilterLists)
        .UsingEntity(
            nameof(FilterListLanguage),
            e =>
        {
            e.ToTable($"{nr.RewriteName(nameof(FilterListLanguage))}s");
            e.Property <long>(nameof(FilterListLanguage.FilterListId));
            e.Property <long>(nameof(FilterListLanguage.LanguageId));
            e.HasKey(nameof(FilterListLanguage.FilterListId), nameof(FilterListLanguage.LanguageId));
        });
        builder.HasMany(f => f.Tags)
        .WithMany(t => t.FilterLists)
        .UsingEntity(
            nameof(FilterListTag),
            e =>
        {
            e.ToTable($"{nr.RewriteName(nameof(FilterListTag))}s");
            e.Property <long>(nameof(FilterListTag.FilterListId));
            e.Property <long>(nameof(FilterListTag.TagId));
            e.HasKey(nameof(FilterListTag.FilterListId), nameof(FilterListTag.TagId));
        });
        builder.OwnsMany(
            f => f.ViewUrls,
            b =>
        {
            b.ToTable($"{nr.RewriteName(nameof(FilterListViewUrl))}s");
            b.Property(u => u.Id)
            .UseHiLo($"EntityFrameworkHiLoSequence-{nameof(FilterListViewUrl)}");
            b.Property(u => u.SegmentNumber)
            .HasDefaultValue(1);
            b.Property(u => u.Primariness)
            .HasDefaultValue(1);
            b.HasIndex(
                nameof(FilterListViewUrl.FilterListId),
                nameof(FilterListViewUrl.SegmentNumber),
                nameof(FilterListViewUrl.Primariness))
            .IsUnique();
        });
        builder.Navigation(f => f.ViewUrls)
        .AutoInclude();
        builder.HasMany(f => f.Maintainers)
        .WithMany(m => m.FilterLists)
        .UsingEntity(
            nameof(FilterListMaintainer),
            e =>
        {
            e.ToTable($"{nr.RewriteName(nameof(FilterListMaintainer))}s");
            e.Property <long>(nameof(FilterListMaintainer.FilterListId));
            e.Property <long>(nameof(FilterListMaintainer.MaintainerId));
            e.HasKey(nameof(FilterListMaintainer.FilterListId), nameof(FilterListMaintainer.MaintainerId));
        });
        builder.HasMany(f => f.UpstreamFilterLists)
        .WithMany(f => f.ForkFilterLists)
        .UsingEntity <Dictionary <string, object> >(
            nameof(Fork),
            rj => rj
            .HasOne <FilterList>()
            .WithMany()
            .HasForeignKey(nameof(Fork.UpstreamFilterListId)),
            lj => lj
            .HasOne <FilterList>()
            .WithMany()
            .HasForeignKey(nameof(Fork.ForkFilterListId)),
            e => e.ToTable($"{nr.RewriteName(nameof(Fork))}s"));
        builder.HasMany(f => f.IncludedInFilterLists)
        .WithMany(f => f.IncludesFilterLists)
        .UsingEntity <Dictionary <string, object> >(
            nameof(Merge),
            rj => rj
            .HasOne <FilterList>()
            .WithMany()
            .HasForeignKey(nameof(Merge.IncludedInFilterListId)),
            lj => lj
            .HasOne <FilterList>()
            .WithMany()
            .HasForeignKey(nameof(Merge.IncludesFilterListId)),
            e => e.ToTable($"{nr.RewriteName(nameof(Merge))}s"));
        builder.HasMany(f => f.DependencyFilterLists)
        .WithMany(f => f.DependentFilterLists)
        .UsingEntity <Dictionary <string, object> >(
            nameof(Dependent),
            rj => rj
            .HasOne <FilterList>()
            .WithMany()
            .HasForeignKey(nameof(Dependent.DependencyFilterListId)),
            lj => lj
            .HasOne <FilterList>()
            .WithMany()
            .HasForeignKey(nameof(Dependent.DependentFilterListId)),
            e => e.ToTable($"{nr.RewriteName(nameof(Dependent))}s"));
        builder.HasMany(f => f.Changes)
        .WithOne()
        .HasForeignKey(nameof(Change.FilterListId));
        builder.Navigation(f => f.Changes)
        .AutoInclude();
    }