-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from AntonioFalcao/feature/code-smells
Upgrade for EF Core 6
- Loading branch information
Showing
6 changed files
with
165 additions
and
165 deletions.
There are no files selected for viewing
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
42 changes: 21 additions & 21 deletions
42
...tories/Configs/Products/BackpackConfig.cs → ...rations/Products/BackpackConfiguration.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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products; | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Backpacks; | ||
using Dotnet5.GraphQL3.Store.Domain.Enumerations; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
namespace Dotnet5.GraphQL3.Store.Repositories.Configs.Products | ||
{ | ||
public class BackpackConfig : IEntityTypeConfiguration<Backpack> | ||
{ | ||
public void Configure(EntityTypeBuilder<Backpack> builder) | ||
{ | ||
builder | ||
.HasBaseType<Product>(); | ||
|
||
builder | ||
.Property(x => x.BackpackType) | ||
.HasConversion(new EnumToStringConverter<BackpackType>()); | ||
} | ||
} | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products; | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Backpacks; | ||
using Dotnet5.GraphQL3.Store.Domain.Enumerations; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
namespace Dotnet5.GraphQL3.Store.Repositories.Configurations.Products | ||
{ | ||
public class BackpackConfiguration : IEntityTypeConfiguration<Backpack> | ||
{ | ||
public void Configure(EntityTypeBuilder<Backpack> builder) | ||
{ | ||
builder | ||
.HasBaseType<Product>(); | ||
|
||
builder | ||
.Property(x => x.BackpackType) | ||
.HasConversion(new EnumToStringConverter<BackpackType>()); | ||
} | ||
} | ||
} |
48 changes: 24 additions & 24 deletions
48
...positories/Configs/Products/BootConfig.cs → ...figurations/Products/BootConfiguration.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 |
---|---|---|
@@ -1,25 +1,25 @@ | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products; | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Boots; | ||
using Dotnet5.GraphQL3.Store.Domain.Enumerations; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
namespace Dotnet5.GraphQL3.Store.Repositories.Configs.Products | ||
{ | ||
public class BootConfig : IEntityTypeConfiguration<Boot> | ||
{ | ||
public void Configure(EntityTypeBuilder<Boot> builder) | ||
{ | ||
builder | ||
.HasBaseType<Product>(); | ||
|
||
builder | ||
.Property(x => x.Size); | ||
|
||
builder | ||
.Property(x => x.BootType) | ||
.HasConversion(new EnumToStringConverter<BootType>()); | ||
} | ||
} | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products; | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Boots; | ||
using Dotnet5.GraphQL3.Store.Domain.Enumerations; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
namespace Dotnet5.GraphQL3.Store.Repositories.Configurations.Products | ||
{ | ||
public class BootConfiguration : IEntityTypeConfiguration<Boot> | ||
{ | ||
public void Configure(EntityTypeBuilder<Boot> builder) | ||
{ | ||
builder | ||
.HasBaseType<Product>(); | ||
|
||
builder | ||
.Property(x => x.Size); | ||
|
||
builder | ||
.Property(x => x.BootType) | ||
.HasConversion(new EnumToStringConverter<BootType>()); | ||
} | ||
} | ||
} |
48 changes: 24 additions & 24 deletions
48
...ositories/Configs/Products/KayakConfig.cs → ...igurations/Products/KayakConfiguration.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 |
---|---|---|
@@ -1,25 +1,25 @@ | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products; | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Kayaks; | ||
using Dotnet5.GraphQL3.Store.Domain.Enumerations; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
namespace Dotnet5.GraphQL3.Store.Repositories.Configs.Products | ||
{ | ||
public class KayakConfig : IEntityTypeConfiguration<Kayak> | ||
{ | ||
public void Configure(EntityTypeBuilder<Kayak> builder) | ||
{ | ||
builder | ||
.HasBaseType<Product>(); | ||
|
||
builder | ||
.Property(x => x.KayakType) | ||
.HasConversion(new EnumToStringConverter<KayakType>()); | ||
|
||
builder | ||
.Property(x => x.AmountOfPerson); | ||
} | ||
} | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products; | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Kayaks; | ||
using Dotnet5.GraphQL3.Store.Domain.Enumerations; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
namespace Dotnet5.GraphQL3.Store.Repositories.Configurations.Products | ||
{ | ||
public class KayakConfiguration : IEntityTypeConfiguration<Kayak> | ||
{ | ||
public void Configure(EntityTypeBuilder<Kayak> builder) | ||
{ | ||
builder | ||
.HasBaseType<Product>(); | ||
|
||
builder | ||
.Property(x => x.KayakType) | ||
.HasConversion(new EnumToStringConverter<KayakType>()); | ||
|
||
builder | ||
.Property(x => x.AmountOfPerson); | ||
} | ||
} | ||
} |
140 changes: 70 additions & 70 deletions
140
...itories/Configs/Products/ProductConfig.cs → ...urations/Products/ProductConfiguration.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 |
---|---|---|
@@ -1,71 +1,71 @@ | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products; | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Backpacks; | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Boots; | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Kayaks; | ||
using Dotnet5.GraphQL3.Store.Domain.Enumerations; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
namespace Dotnet5.GraphQL3.Store.Repositories.Configs.Products | ||
{ | ||
public class ProductConfig : IEntityTypeConfiguration<Product> | ||
{ | ||
private const string DiscriminatorDefaultName = "Discriminator"; | ||
|
||
public void Configure(EntityTypeBuilder<Product> builder) | ||
{ | ||
builder | ||
.HasKey(x => x.Id); | ||
|
||
builder | ||
.Property(x => x.Description) | ||
.HasMaxLength(300); | ||
|
||
builder | ||
.Property(x => x.IntroduceAt); | ||
|
||
builder | ||
.Property(x => x.Name) | ||
.HasMaxLength(50) | ||
.IsRequired(); | ||
|
||
builder | ||
.Property(x => x.PhotoUrl) | ||
.HasMaxLength(100); | ||
|
||
builder | ||
.Property(x => x.Price) | ||
.HasPrecision(18, 2) | ||
.IsRequired(); | ||
|
||
builder | ||
.Property(x => x.Option) | ||
.HasConversion(new EnumToStringConverter<Option>()); | ||
|
||
builder | ||
.Property(x => x.Rating); | ||
|
||
builder | ||
.Property(x => x.Stock); | ||
|
||
builder | ||
.HasOne(x => x.ProductType); | ||
|
||
builder | ||
.HasMany(x => x.Reviews) | ||
.WithOne(x => x.Product) | ||
.HasForeignKey(x => x.ProductId); | ||
|
||
builder | ||
.HasDiscriminator() | ||
.HasValue<Boot>(nameof(Boot)) | ||
.HasValue<Kayak>(nameof(Kayak)) | ||
.HasValue<Backpack>(nameof(Backpack)); | ||
|
||
builder | ||
.Property(DiscriminatorDefaultName) | ||
.HasMaxLength(30); | ||
} | ||
} | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products; | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Backpacks; | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Boots; | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Kayaks; | ||
using Dotnet5.GraphQL3.Store.Domain.Enumerations; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
namespace Dotnet5.GraphQL3.Store.Repositories.Configurations.Products | ||
{ | ||
public class ProductConfiguration : IEntityTypeConfiguration<Product> | ||
{ | ||
private const string DiscriminatorDefaultName = "Discriminator"; | ||
|
||
public void Configure(EntityTypeBuilder<Product> builder) | ||
{ | ||
builder | ||
.HasKey(x => x.Id); | ||
|
||
builder | ||
.Property(x => x.Description) | ||
.HasMaxLength(300); | ||
|
||
builder | ||
.Property(x => x.IntroduceAt); | ||
|
||
builder | ||
.Property(x => x.Name) | ||
.HasMaxLength(50) | ||
.IsRequired(); | ||
|
||
builder | ||
.Property(x => x.PhotoUrl) | ||
.HasMaxLength(100); | ||
|
||
builder | ||
.Property(x => x.Price) | ||
.HasPrecision(10, 2) | ||
.IsRequired(); | ||
|
||
builder | ||
.Property(x => x.Option) | ||
.HasConversion(new EnumToStringConverter<Option>()); | ||
|
||
builder | ||
.Property(x => x.Rating); | ||
|
||
builder | ||
.Property(x => x.Stock); | ||
|
||
builder | ||
.HasOne(x => x.ProductType); | ||
|
||
builder | ||
.HasMany(x => x.Reviews) | ||
.WithOne(x => x.Product) | ||
.HasForeignKey(x => x.ProductId); | ||
|
||
builder | ||
.HasDiscriminator() | ||
.HasValue<Boot>(nameof(Boot)) | ||
?.HasValue<Kayak>(nameof(Kayak)) | ||
?.HasValue<Backpack>(nameof(Backpack)); | ||
|
||
builder | ||
.Property(DiscriminatorDefaultName) | ||
.HasMaxLength(30); | ||
} | ||
} | ||
} |
50 changes: 25 additions & 25 deletions
50
...ositories/Configs/Reviews/ReviewConfig.cs → ...igurations/Reviews/ReviewConfiguration.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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Reviews; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Dotnet5.GraphQL3.Store.Repositories.Configs.Reviews | ||
{ | ||
public class ReviewConfig : IEntityTypeConfiguration<Review> | ||
{ | ||
public void Configure(EntityTypeBuilder<Review> builder) | ||
{ | ||
builder | ||
.HasKey(x => x.Id); | ||
|
||
builder | ||
.Property(x => x.Comment); | ||
|
||
builder | ||
.Property(x => x.Title) | ||
.HasMaxLength(100); | ||
|
||
builder | ||
.HasOne(x => x.Product) | ||
.WithMany(x => x.Reviews); | ||
} | ||
} | ||
using Dotnet5.GraphQL3.Store.Domain.Entities.Reviews; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Dotnet5.GraphQL3.Store.Repositories.Configurations.Reviews | ||
{ | ||
public class ReviewConfiguration : IEntityTypeConfiguration<Review> | ||
{ | ||
public void Configure(EntityTypeBuilder<Review> builder) | ||
{ | ||
builder | ||
.HasKey(x => x.Id); | ||
|
||
builder | ||
.Property(x => x.Comment); | ||
|
||
builder | ||
.Property(x => x.Title) | ||
.HasMaxLength(100); | ||
|
||
builder | ||
.HasOne(x => x.Product) | ||
.WithMany(x => x.Reviews); | ||
} | ||
} | ||
} |