-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved all ef core entity configuration out of the DB Context class an…
…d into separate EntityConfig classes for each entity in the EntityConfiguration folder
- Loading branch information
1 parent
d0d9ed3
commit a41c2c4
Showing
20 changed files
with
546 additions
and
329 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/Abm.Pyro.Repository/EntityConfiguration/ComparatorEntityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Abm.Pyro.Domain.Enums; | ||
using Abm.Pyro.Domain.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Abm.Pyro.Repository.EntityConfiguration; | ||
|
||
public class ComparatorEntityConfig : IEntityTypeConfiguration<Comparator> | ||
{ | ||
public void Configure(EntityTypeBuilder<Comparator> builder) | ||
{ | ||
// Comparator --------------------------------------------------------------- | ||
builder.HasKey(x => x.SearchComparatorId); | ||
|
||
builder.Property(x => x.SearchComparatorId).HasConversion<int>(); | ||
builder.Property(x => x.Name).HasMaxLength(RepositoryModelConstraints.CodeMaxLength); | ||
|
||
builder.HasData( | ||
Enum.GetValues(typeof(SearchComparatorId)) | ||
.Cast<SearchComparatorId>() | ||
.Select(e => new Comparator(e, e.ToString()))); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Abm.Pyro.Repository/EntityConfiguration/HttpVerbEntityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Abm.Pyro.Domain.Enums; | ||
using Abm.Pyro.Domain.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Abm.Pyro.Repository.EntityConfiguration; | ||
|
||
public class HttpVerbEntityConfig : IEntityTypeConfiguration<HttpVerb> | ||
{ | ||
public void Configure(EntityTypeBuilder<HttpVerb> builder) | ||
{ | ||
// HttpVerb ----------------------------------------------------------------- | ||
builder.HasKey(x => x.HttpVerbId); | ||
|
||
builder.Property(x => x.HttpVerbId).HasConversion<int>(); | ||
builder.Property(x => x.Name).HasMaxLength(RepositoryModelConstraints.CodeMaxLength); | ||
|
||
builder.HasData( | ||
Enum.GetValues(typeof(HttpVerbId)) | ||
.Cast<HttpVerbId>() | ||
.Select(e => new HttpVerb(e, e.ToString()))); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Abm.Pyro.Repository/EntityConfiguration/IndexDateTimeEntityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Abm.Pyro.Domain.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Abm.Pyro.Repository.EntityConfiguration; | ||
|
||
public class IndexDateTimeEntityConfig : IEntityTypeConfiguration<IndexDateTime> | ||
{ | ||
public void Configure(EntityTypeBuilder<IndexDateTime> builder) | ||
{ | ||
// IndexDateTime --------------------------------------------------------------- | ||
builder.HasKey(x => x.IndexDateTimeId); | ||
builder.HasIndex(x => x.LowUtc); | ||
builder.HasIndex(x => x.HighUtc); | ||
|
||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/Abm.Pyro.Repository/EntityConfiguration/IndexQuantityEntityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Abm.Pyro.Domain.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Abm.Pyro.Repository.EntityConfiguration; | ||
|
||
public class IndexQuantityEntityConfig : IEntityTypeConfiguration<IndexQuantity> | ||
{ | ||
public void Configure( | ||
EntityTypeBuilder<IndexQuantity> builder) | ||
{ | ||
// IndexQuantity --------------------------------------------------------------- | ||
builder.HasKey(x => x.IndexQuantityId); | ||
builder.HasIndex(x => x.Code); | ||
builder.HasIndex(x => x.System); | ||
builder.HasIndex(x => x.Quantity); | ||
builder.HasIndex(x => x.CodeHigh); | ||
builder.HasIndex(x => x.SystemHigh); | ||
builder.HasIndex(x => x.QuantityHigh); | ||
|
||
builder.Property(x => x.Code).HasMaxLength(RepositoryModelConstraints.CodeMaxLength); | ||
builder.Property(x => x.System).HasMaxLength(RepositoryModelConstraints.StringMaxLength); | ||
builder.Property(x => x.Quantity).HasPrecision( | ||
RepositoryModelConstraints.QuantityPrecision, | ||
RepositoryModelConstraints.QuantityScale); | ||
builder.Property(x => x.Unit).HasMaxLength(RepositoryModelConstraints.CodeMaxLength); | ||
|
||
builder.Property(x => x.CodeHigh).HasMaxLength(RepositoryModelConstraints.CodeMaxLength); | ||
builder.Property(x => x.SystemHigh).HasMaxLength(RepositoryModelConstraints.StringMaxLength); | ||
builder.Property(x => x.QuantityHigh).HasPrecision( | ||
RepositoryModelConstraints.QuantityPrecision, | ||
RepositoryModelConstraints.QuantityScale); | ||
builder.Property(x => x.UnitHigh).HasMaxLength(RepositoryModelConstraints.CodeMaxLength); | ||
|
||
builder | ||
.HasOne<ResourceStore>(x => x.ResourceStore) | ||
.WithMany(x => x.IndexQuantityList) | ||
.HasForeignKey(x => x.ResourceStoreId) | ||
.OnDelete(DeleteBehavior.Cascade); | ||
|
||
builder | ||
.HasOne<SearchParameterStore>(x => x.SearchParameterStore) | ||
.WithMany() | ||
.HasForeignKey(x => x.SearchParameterStoreId) | ||
.OnDelete(DeleteBehavior.NoAction); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/Abm.Pyro.Repository/EntityConfiguration/IndexReferenceEntityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Abm.Pyro.Domain.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Abm.Pyro.Repository.EntityConfiguration; | ||
|
||
public class IndexReferenceEntityConfig : IEntityTypeConfiguration<IndexReference> | ||
{ | ||
public void Configure(EntityTypeBuilder<IndexReference> builder) | ||
{ | ||
// IndexReference --------------------------------------------------------------- | ||
|
||
builder.HasKey(x => x.IndexReferenceId); | ||
builder.HasIndex(x => x.ResourceId); | ||
builder.HasIndex(x => x.VersionId); | ||
builder.HasIndex(x => x.CanonicalVersionId); | ||
|
||
builder.Property(x => x.ResourceId) | ||
.UseCollation(RepositoryModelConstraints.CaseSensitive) | ||
.HasMaxLength(RepositoryModelConstraints.FhirIdMaxLength); | ||
builder.Property(x => x.VersionId) | ||
.HasMaxLength(RepositoryModelConstraints.FhirIdMaxLength); | ||
builder.Property(x => x.CanonicalVersionId) | ||
.HasMaxLength(RepositoryModelConstraints.FhirIdMaxLength); | ||
|
||
builder | ||
.HasOne<ResourceStore>(x => x.ResourceStore) | ||
.WithMany(x => x.IndexReferenceList) | ||
.HasForeignKey(x => x.ResourceStoreId) | ||
.OnDelete(DeleteBehavior.Cascade); | ||
|
||
builder | ||
.HasOne<ServiceBaseUrl>(x => x.ServiceBaseUrl) | ||
.WithMany() | ||
.HasForeignKey(x => x.ServiceBaseUrlId) | ||
.OnDelete(DeleteBehavior.NoAction); | ||
|
||
builder | ||
.HasOne<SearchParameterStore>(x => x.SearchParameterStore) | ||
.WithMany() | ||
.HasForeignKey(x => x.SearchParameterStoreId) | ||
.OnDelete(DeleteBehavior.NoAction); | ||
|
||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/Abm.Pyro.Repository/EntityConfiguration/IndexStringEntityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Abm.Pyro.Domain.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Abm.Pyro.Repository.EntityConfiguration; | ||
|
||
public class IndexStringEntityConfig : IEntityTypeConfiguration<IndexString> | ||
{ | ||
public void Configure(EntityTypeBuilder<IndexString> builder) | ||
{ | ||
// IndexString --------------------------------------------------------------- | ||
builder.HasKey(x => x.IndexStringId); | ||
builder.HasIndex(x => x.Value); | ||
|
||
builder.Property(x => x.Value); | ||
|
||
builder | ||
.HasOne<ResourceStore>(x => x.ResourceStore) | ||
.WithMany(x => x.IndexStringList) | ||
.HasForeignKey(x => x.ResourceStoreId) | ||
.OnDelete(DeleteBehavior.Cascade); | ||
|
||
builder | ||
.HasOne<SearchParameterStore>(x => x.SearchParameterStore) | ||
.WithMany() | ||
.HasForeignKey(x => x.SearchParameterStoreId) | ||
.OnDelete(DeleteBehavior.NoAction); | ||
|
||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/Abm.Pyro.Repository/EntityConfiguration/IndexTokenEntityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Abm.Pyro.Domain.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Abm.Pyro.Repository.EntityConfiguration; | ||
|
||
public class IndexTokenEntityConfig : IEntityTypeConfiguration<IndexToken> | ||
{ | ||
public void Configure(EntityTypeBuilder<IndexToken> builder) | ||
{ | ||
// IndexToken --------------------------------------------------------------- | ||
builder.HasKey(x => x.IndexTokenId); | ||
builder.HasIndex(x => x.System); | ||
builder.HasIndex(x => x.Code); | ||
|
||
builder.Property(x => x.System).HasMaxLength(RepositoryModelConstraints.StringMaxLength); | ||
builder.Property(x => x.Code).HasMaxLength(RepositoryModelConstraints.CodeMaxLength); | ||
|
||
builder | ||
.HasOne<ResourceStore>(x => x.ResourceStore) | ||
.WithMany(x => x.IndexTokenList) | ||
.HasForeignKey(x => x.ResourceStoreId) | ||
.OnDelete(DeleteBehavior.Cascade); | ||
|
||
builder | ||
.HasOne<SearchParameterStore>(x => x.SearchParameterStore) | ||
.WithMany() | ||
.HasForeignKey(x => x.SearchParameterStoreId) | ||
.OnDelete(DeleteBehavior.NoAction); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Abm.Pyro.Repository/EntityConfiguration/IndexUriEntityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Abm.Pyro.Domain.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Abm.Pyro.Repository.EntityConfiguration; | ||
|
||
public class IndexUriEntityConfig : IEntityTypeConfiguration<IndexUri> | ||
{ | ||
public void Configure(EntityTypeBuilder<IndexUri> builder) | ||
{ | ||
// IndexUri --------------------------------------------------------------- | ||
builder.HasKey(x => x.IndexUriId); | ||
builder.HasIndex(x => x.Uri); | ||
|
||
builder.Property(x => x.Uri).HasMaxLength(RepositoryModelConstraints.StringMaxLength);; | ||
|
||
builder | ||
.HasOne<ResourceStore>(x => x.ResourceStore) | ||
.WithMany(x => x.IndexUriList) | ||
.HasForeignKey(x => x.ResourceStoreId) | ||
.OnDelete(DeleteBehavior.Cascade); | ||
|
||
builder | ||
.HasOne<SearchParameterStore>(x => x.SearchParameterStore) | ||
.WithMany() | ||
.HasForeignKey(x => x.SearchParameterStoreId) | ||
.OnDelete(DeleteBehavior.NoAction); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Abm.Pyro.Repository/EntityConfiguration/PublicationStatusEntityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Abm.Pyro.Domain.Enums; | ||
using Abm.Pyro.Domain.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Abm.Pyro.Repository.EntityConfiguration; | ||
|
||
public class PublicationStatusEntityConfig : IEntityTypeConfiguration<PublicationStatus> | ||
{ | ||
public void Configure(EntityTypeBuilder<PublicationStatus> builder) | ||
{ | ||
// PublicationStatus -------------------------------------------------------- | ||
builder.HasKey(x => x.PublicationStatusId); | ||
|
||
builder.Property(x => x.PublicationStatusId).HasConversion<int>(); | ||
builder.Property(x => x.Name).HasMaxLength(RepositoryModelConstraints.CodeMaxLength); | ||
|
||
builder.HasData( | ||
Enum.GetValues(typeof(PublicationStatusId)) | ||
.Cast<PublicationStatusId>() | ||
.Select(e => new PublicationStatus(e, e.ToString()))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/Abm.Pyro.Repository/EntityConfiguration/ResourceTypeEntityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Abm.Pyro.Domain.Enums; | ||
using Abm.Pyro.Domain.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Abm.Pyro.Repository.EntityConfiguration; | ||
|
||
public class ResourceTypeEntityConfig : IEntityTypeConfiguration<ResourceType> | ||
{ | ||
public void Configure(EntityTypeBuilder<ResourceType> builder) | ||
{ | ||
// ResourceType --------------------------------------------------------------- | ||
builder.HasKey(x => x.FhirResourceType); | ||
|
||
builder.Property(x => x.FhirResourceType).HasConversion<int>(); | ||
builder.Property(x => x.Name).HasMaxLength(RepositoryModelConstraints.FhirResourceNameMaxLength); | ||
|
||
builder.HasData( | ||
Enum.GetValues(typeof(FhirResourceTypeId)) | ||
.Cast<FhirResourceTypeId>() | ||
.Select(e => new ResourceType(e, e.ToString()))); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Abm.Pyro.Repository/EntityConfiguration/SearchModifierCodeEntityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Abm.Pyro.Domain.Enums; | ||
using Abm.Pyro.Domain.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Abm.Pyro.Repository.EntityConfiguration; | ||
|
||
public class SearchModifierCodeEntityConfig : IEntityTypeConfiguration<SearchModifierCode> | ||
{ | ||
public void Configure(EntityTypeBuilder<SearchModifierCode> builder) | ||
{ | ||
// SearchModifierCode --------------------------------------------------------------- | ||
builder.HasKey(x => x.SearchModifierCodeId); | ||
|
||
builder.Property(x => x.SearchModifierCodeId).HasConversion<int>(); | ||
builder.Property(x => x.Name).HasMaxLength(RepositoryModelConstraints.CodeMaxLength); | ||
|
||
builder.HasData( | ||
Enum.GetValues(typeof(SearchModifierCodeId)) | ||
.Cast<SearchModifierCodeId>() | ||
.Select(e => new SearchModifierCode(e, e.ToString()))); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Abm.Pyro.Repository/EntityConfiguration/SearchParameterStoreComparatorEntityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Abm.Pyro.Domain.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Abm.Pyro.Repository.EntityConfiguration; | ||
|
||
public class SearchParameterStoreComparatorEntityConfig : IEntityTypeConfiguration<SearchParameterStoreComparator> | ||
{ | ||
public void Configure(EntityTypeBuilder<SearchParameterStoreComparator> builder) | ||
{ | ||
// SearchParameterStoreComparator --------------------------------------------------------------- | ||
builder.HasKey(x => x.SearchParameterStoreComparatorId); | ||
builder.HasIndex(x => x.SearchParameterStoreId); | ||
|
||
builder.Property(x => x.SearchParameterStoreId); | ||
builder.Property(x => x.SearchComparatorId).HasConversion<int>(); | ||
builder.HasData(Seed.SearchParameterStoreComparatorSeed.Get()); | ||
|
||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Abm.Pyro.Repository/EntityConfiguration/SearchParameterStoreComponentEntityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Abm.Pyro.Domain.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Abm.Pyro.Repository.EntityConfiguration; | ||
|
||
public class SearchParameterStoreComponentEntityConfig : IEntityTypeConfiguration<SearchParameterStoreComponent> | ||
{ | ||
public void Configure(EntityTypeBuilder<SearchParameterStoreComponent> builder) | ||
{ | ||
// SearchParameterStoreComponent --------------------------------------------------------------- | ||
builder.HasKey(x => x.SearchParameterStoreComponentId); | ||
builder.HasIndex(x => x.SearchParameterStoreId); | ||
|
||
builder.Property(x => x.SearchParameterStoreId); | ||
builder.Property(x => x.Definition); | ||
builder.Property(x => x.Expression); | ||
builder.HasData(Seed.SearchParameterStoreComponentSeed.Get()); | ||
} | ||
} |
Oops, something went wrong.