feat(directory): add explicit Id props to primary query entities

This commit is contained in:
Collin M. Barrett 2020-08-25 06:39:08 -05:00
parent 992ecaba2d
commit 380c8d98f4
6 changed files with 7 additions and 86 deletions

View file

@ -1,14 +1,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
{
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")]
public class FilterList
{
public int Id { get; private set; }
public string Name { get; private set; } = null!;
public string? Description { get; private set; }
public License? License { get; private set; }
@ -33,16 +32,4 @@ public class FilterList
public IReadOnlyCollection<Dependent> DependencyFilterLists { get; private set; } = new HashSet<Dependent>();
public IReadOnlyCollection<Dependent> DependentFilterLists { get; private set; } = new HashSet<Dependent>();
}
internal class FilterListTypeConfiguration : IEntityTypeConfiguration<FilterList>
{
public virtual void Configure(EntityTypeBuilder<FilterList> builder)
{
_ = builder ?? throw new ArgumentNullException(nameof(builder));
const string filterListId = "Id";
builder.Property<int>(filterListId);
builder.HasKey(filterListId);
}
}
}

View file

@ -1,29 +1,16 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
{
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")]
public class License
{
public int Id { get; private set; }
public string Name { get; private set; } = null!;
public string? GitHubKey { get; private set; }
public Uri? Url { get; private set; }
public IReadOnlyCollection<FilterList> FilterLists { get; private set; } = new HashSet<FilterList>();
}
internal class LicenseTypeConfiguration : IEntityTypeConfiguration<License>
{
public virtual void Configure(EntityTypeBuilder<License> builder)
{
_ = builder ?? throw new ArgumentNullException(nameof(builder));
const string licenseId = "Id";
builder.Property<int>(licenseId);
builder.HasKey(licenseId);
}
}
}

View file

@ -1,30 +1,17 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
{
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")]
public class Maintainer
{
public int Id { get; private set; }
public string Name { get; private set; } = null!;
public Uri? Url { get; private set; }
public string? EmailAddress { get; private set; }
public string? TwitterHandle { get; private set; }
public IReadOnlyCollection<FilterListMaintainer> FilterListMaintainers { get; private set; } = new HashSet<FilterListMaintainer>();
}
internal class MaintainerTypeConfiguration : IEntityTypeConfiguration<Maintainer>
{
public virtual void Configure(EntityTypeBuilder<Maintainer> builder)
{
_ = builder ?? throw new ArgumentNullException(nameof(builder));
const string maintainerId = "Id";
builder.Property<int>(maintainerId);
builder.HasKey(maintainerId);
}
}
}

View file

@ -1,14 +1,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
{
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")]
public class Software
{
public int Id { get; private set; }
public string Name { get; private set; } = null!;
public string? Description { get; private set; }
public Uri? HomeUrl { get; private set; }
@ -16,16 +15,4 @@ public class Software
public bool SupportsAbpUrlScheme { get; private set; }
public IReadOnlyCollection<SoftwareSyntax> SoftwareSyntaxes { get; private set; } = new HashSet<SoftwareSyntax>();
}
internal class SoftwareTypeConfiguration : IEntityTypeConfiguration<Software>
{
public virtual void Configure(EntityTypeBuilder<Software> builder)
{
_ = builder ?? throw new ArgumentNullException(nameof(builder));
const string softwareId = "Id";
builder.Property<int>(softwareId);
builder.HasKey(softwareId);
}
}
}

View file

@ -1,30 +1,17 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
{
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")]
public class Syntax
{
public int Id { get; private set; }
public string Name { get; private set; } = null!;
public string? Description { get; private set; }
public Uri? Url { get; private set; }
public IReadOnlyCollection<FilterListSyntax> FilterListSyntaxes { get; private set; } = new HashSet<FilterListSyntax>();
public IReadOnlyCollection<SoftwareSyntax> SoftwareSyntaxes { get; private set; } = new HashSet<SoftwareSyntax>();
}
internal class SyntaxTypeConfiguration : IEntityTypeConfiguration<Syntax>
{
public virtual void Configure(EntityTypeBuilder<Syntax> builder)
{
_ = builder ?? throw new ArgumentNullException(nameof(builder));
const string syntaxId = "Id";
builder.Property<int>(syntaxId);
builder.HasKey(syntaxId);
}
}
}

View file

@ -1,28 +1,14 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
{
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")]
public class Tag
{
public int Id { get; private set; }
public string Name { get; private set; } = null!;
public string? Description { get; private set; }
public IReadOnlyCollection<FilterListTag> FilterListTags { get; private set; } = new HashSet<FilterListTag>();
}
internal class TagTypeConfiguration : IEntityTypeConfiguration<Tag>
{
public virtual void Configure(EntityTypeBuilder<Tag> builder)
{
_ = builder ?? throw new ArgumentNullException(nameof(builder));
const string tagId = "Id";
builder.Property<int>(tagId);
builder.HasKey(tagId);
}
}
}