Skip to content

Commit

Permalink
Merge pull request #157 from AntonioFalcao/feature/code-smells
Browse files Browse the repository at this point in the history
Upgrade for EF Core 6
  • Loading branch information
AntonioFalcaoJr authored Mar 10, 2021
2 parents 7f3d917 + 07d7b26 commit 1c3253d
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 165 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Microsoft_DependencyInjection_Version>5.0.0</Microsoft_DependencyInjection_Version>

<!--EF Core-->
<Microsoft_EntityFrameworkCore_Version>5.0.3</Microsoft_EntityFrameworkCore_Version>
<Microsoft_EntityFrameworkCore_Version>6.0.0-preview.1.21102.2</Microsoft_EntityFrameworkCore_Version>

<!--GraphQL-->
<GraphQL_Server_Version>4.4.1</GraphQL_Server_Version>
Expand Down
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>());
}
}
}
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>());
}
}
}
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);
}
}
}
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);
}
}
}
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);
}
}
}

0 comments on commit 1c3253d

Please sign in to comment.