Skip to content

Commit 1c3253d

Browse files
Merge pull request #157 from AntonioFalcao/feature/code-smells
Upgrade for EF Core 6
2 parents 7f3d917 + 07d7b26 commit 1c3253d

File tree

6 files changed

+165
-165
lines changed

6 files changed

+165
-165
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Microsoft_DependencyInjection_Version>5.0.0</Microsoft_DependencyInjection_Version>
1111

1212
<!--EF Core-->
13-
<Microsoft_EntityFrameworkCore_Version>5.0.3</Microsoft_EntityFrameworkCore_Version>
13+
<Microsoft_EntityFrameworkCore_Version>6.0.0-preview.1.21102.2</Microsoft_EntityFrameworkCore_Version>
1414

1515
<!--GraphQL-->
1616
<GraphQL_Server_Version>4.4.1</GraphQL_Server_Version>
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
using Dotnet5.GraphQL3.Store.Domain.Entities.Products;
2-
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Backpacks;
3-
using Dotnet5.GraphQL3.Store.Domain.Enumerations;
4-
using Microsoft.EntityFrameworkCore;
5-
using Microsoft.EntityFrameworkCore.Metadata.Builders;
6-
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7-
8-
namespace Dotnet5.GraphQL3.Store.Repositories.Configs.Products
9-
{
10-
public class BackpackConfig : IEntityTypeConfiguration<Backpack>
11-
{
12-
public void Configure(EntityTypeBuilder<Backpack> builder)
13-
{
14-
builder
15-
.HasBaseType<Product>();
16-
17-
builder
18-
.Property(x => x.BackpackType)
19-
.HasConversion(new EnumToStringConverter<BackpackType>());
20-
}
21-
}
1+
using Dotnet5.GraphQL3.Store.Domain.Entities.Products;
2+
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Backpacks;
3+
using Dotnet5.GraphQL3.Store.Domain.Enumerations;
4+
using Microsoft.EntityFrameworkCore;
5+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
6+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7+
8+
namespace Dotnet5.GraphQL3.Store.Repositories.Configurations.Products
9+
{
10+
public class BackpackConfiguration : IEntityTypeConfiguration<Backpack>
11+
{
12+
public void Configure(EntityTypeBuilder<Backpack> builder)
13+
{
14+
builder
15+
.HasBaseType<Product>();
16+
17+
builder
18+
.Property(x => x.BackpackType)
19+
.HasConversion(new EnumToStringConverter<BackpackType>());
20+
}
21+
}
2222
}
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
using Dotnet5.GraphQL3.Store.Domain.Entities.Products;
2-
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Boots;
3-
using Dotnet5.GraphQL3.Store.Domain.Enumerations;
4-
using Microsoft.EntityFrameworkCore;
5-
using Microsoft.EntityFrameworkCore.Metadata.Builders;
6-
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7-
8-
namespace Dotnet5.GraphQL3.Store.Repositories.Configs.Products
9-
{
10-
public class BootConfig : IEntityTypeConfiguration<Boot>
11-
{
12-
public void Configure(EntityTypeBuilder<Boot> builder)
13-
{
14-
builder
15-
.HasBaseType<Product>();
16-
17-
builder
18-
.Property(x => x.Size);
19-
20-
builder
21-
.Property(x => x.BootType)
22-
.HasConversion(new EnumToStringConverter<BootType>());
23-
}
24-
}
1+
using Dotnet5.GraphQL3.Store.Domain.Entities.Products;
2+
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Boots;
3+
using Dotnet5.GraphQL3.Store.Domain.Enumerations;
4+
using Microsoft.EntityFrameworkCore;
5+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
6+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7+
8+
namespace Dotnet5.GraphQL3.Store.Repositories.Configurations.Products
9+
{
10+
public class BootConfiguration : IEntityTypeConfiguration<Boot>
11+
{
12+
public void Configure(EntityTypeBuilder<Boot> builder)
13+
{
14+
builder
15+
.HasBaseType<Product>();
16+
17+
builder
18+
.Property(x => x.Size);
19+
20+
builder
21+
.Property(x => x.BootType)
22+
.HasConversion(new EnumToStringConverter<BootType>());
23+
}
24+
}
2525
}
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
using Dotnet5.GraphQL3.Store.Domain.Entities.Products;
2-
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Kayaks;
3-
using Dotnet5.GraphQL3.Store.Domain.Enumerations;
4-
using Microsoft.EntityFrameworkCore;
5-
using Microsoft.EntityFrameworkCore.Metadata.Builders;
6-
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7-
8-
namespace Dotnet5.GraphQL3.Store.Repositories.Configs.Products
9-
{
10-
public class KayakConfig : IEntityTypeConfiguration<Kayak>
11-
{
12-
public void Configure(EntityTypeBuilder<Kayak> builder)
13-
{
14-
builder
15-
.HasBaseType<Product>();
16-
17-
builder
18-
.Property(x => x.KayakType)
19-
.HasConversion(new EnumToStringConverter<KayakType>());
20-
21-
builder
22-
.Property(x => x.AmountOfPerson);
23-
}
24-
}
1+
using Dotnet5.GraphQL3.Store.Domain.Entities.Products;
2+
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Kayaks;
3+
using Dotnet5.GraphQL3.Store.Domain.Enumerations;
4+
using Microsoft.EntityFrameworkCore;
5+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
6+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7+
8+
namespace Dotnet5.GraphQL3.Store.Repositories.Configurations.Products
9+
{
10+
public class KayakConfiguration : IEntityTypeConfiguration<Kayak>
11+
{
12+
public void Configure(EntityTypeBuilder<Kayak> builder)
13+
{
14+
builder
15+
.HasBaseType<Product>();
16+
17+
builder
18+
.Property(x => x.KayakType)
19+
.HasConversion(new EnumToStringConverter<KayakType>());
20+
21+
builder
22+
.Property(x => x.AmountOfPerson);
23+
}
24+
}
2525
}
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
using Dotnet5.GraphQL3.Store.Domain.Entities.Products;
2-
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Backpacks;
3-
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Boots;
4-
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Kayaks;
5-
using Dotnet5.GraphQL3.Store.Domain.Enumerations;
6-
using Microsoft.EntityFrameworkCore;
7-
using Microsoft.EntityFrameworkCore.Metadata.Builders;
8-
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
9-
10-
namespace Dotnet5.GraphQL3.Store.Repositories.Configs.Products
11-
{
12-
public class ProductConfig : IEntityTypeConfiguration<Product>
13-
{
14-
private const string DiscriminatorDefaultName = "Discriminator";
15-
16-
public void Configure(EntityTypeBuilder<Product> builder)
17-
{
18-
builder
19-
.HasKey(x => x.Id);
20-
21-
builder
22-
.Property(x => x.Description)
23-
.HasMaxLength(300);
24-
25-
builder
26-
.Property(x => x.IntroduceAt);
27-
28-
builder
29-
.Property(x => x.Name)
30-
.HasMaxLength(50)
31-
.IsRequired();
32-
33-
builder
34-
.Property(x => x.PhotoUrl)
35-
.HasMaxLength(100);
36-
37-
builder
38-
.Property(x => x.Price)
39-
.HasPrecision(18, 2)
40-
.IsRequired();
41-
42-
builder
43-
.Property(x => x.Option)
44-
.HasConversion(new EnumToStringConverter<Option>());
45-
46-
builder
47-
.Property(x => x.Rating);
48-
49-
builder
50-
.Property(x => x.Stock);
51-
52-
builder
53-
.HasOne(x => x.ProductType);
54-
55-
builder
56-
.HasMany(x => x.Reviews)
57-
.WithOne(x => x.Product)
58-
.HasForeignKey(x => x.ProductId);
59-
60-
builder
61-
.HasDiscriminator()
62-
.HasValue<Boot>(nameof(Boot))
63-
.HasValue<Kayak>(nameof(Kayak))
64-
.HasValue<Backpack>(nameof(Backpack));
65-
66-
builder
67-
.Property(DiscriminatorDefaultName)
68-
.HasMaxLength(30);
69-
}
70-
}
1+
using Dotnet5.GraphQL3.Store.Domain.Entities.Products;
2+
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Backpacks;
3+
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Boots;
4+
using Dotnet5.GraphQL3.Store.Domain.Entities.Products.Kayaks;
5+
using Dotnet5.GraphQL3.Store.Domain.Enumerations;
6+
using Microsoft.EntityFrameworkCore;
7+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
8+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
9+
10+
namespace Dotnet5.GraphQL3.Store.Repositories.Configurations.Products
11+
{
12+
public class ProductConfiguration : IEntityTypeConfiguration<Product>
13+
{
14+
private const string DiscriminatorDefaultName = "Discriminator";
15+
16+
public void Configure(EntityTypeBuilder<Product> builder)
17+
{
18+
builder
19+
.HasKey(x => x.Id);
20+
21+
builder
22+
.Property(x => x.Description)
23+
.HasMaxLength(300);
24+
25+
builder
26+
.Property(x => x.IntroduceAt);
27+
28+
builder
29+
.Property(x => x.Name)
30+
.HasMaxLength(50)
31+
.IsRequired();
32+
33+
builder
34+
.Property(x => x.PhotoUrl)
35+
.HasMaxLength(100);
36+
37+
builder
38+
.Property(x => x.Price)
39+
.HasPrecision(10, 2)
40+
.IsRequired();
41+
42+
builder
43+
.Property(x => x.Option)
44+
.HasConversion(new EnumToStringConverter<Option>());
45+
46+
builder
47+
.Property(x => x.Rating);
48+
49+
builder
50+
.Property(x => x.Stock);
51+
52+
builder
53+
.HasOne(x => x.ProductType);
54+
55+
builder
56+
.HasMany(x => x.Reviews)
57+
.WithOne(x => x.Product)
58+
.HasForeignKey(x => x.ProductId);
59+
60+
builder
61+
.HasDiscriminator()
62+
.HasValue<Boot>(nameof(Boot))
63+
?.HasValue<Kayak>(nameof(Kayak))
64+
?.HasValue<Backpack>(nameof(Backpack));
65+
66+
builder
67+
.Property(DiscriminatorDefaultName)
68+
.HasMaxLength(30);
69+
}
70+
}
7171
}
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
using Dotnet5.GraphQL3.Store.Domain.Entities.Reviews;
2-
using Microsoft.EntityFrameworkCore;
3-
using Microsoft.EntityFrameworkCore.Metadata.Builders;
4-
5-
namespace Dotnet5.GraphQL3.Store.Repositories.Configs.Reviews
6-
{
7-
public class ReviewConfig : IEntityTypeConfiguration<Review>
8-
{
9-
public void Configure(EntityTypeBuilder<Review> builder)
10-
{
11-
builder
12-
.HasKey(x => x.Id);
13-
14-
builder
15-
.Property(x => x.Comment);
16-
17-
builder
18-
.Property(x => x.Title)
19-
.HasMaxLength(100);
20-
21-
builder
22-
.HasOne(x => x.Product)
23-
.WithMany(x => x.Reviews);
24-
}
25-
}
1+
using Dotnet5.GraphQL3.Store.Domain.Entities.Reviews;
2+
using Microsoft.EntityFrameworkCore;
3+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
4+
5+
namespace Dotnet5.GraphQL3.Store.Repositories.Configurations.Reviews
6+
{
7+
public class ReviewConfiguration : IEntityTypeConfiguration<Review>
8+
{
9+
public void Configure(EntityTypeBuilder<Review> builder)
10+
{
11+
builder
12+
.HasKey(x => x.Id);
13+
14+
builder
15+
.Property(x => x.Comment);
16+
17+
builder
18+
.Property(x => x.Title)
19+
.HasMaxLength(100);
20+
21+
builder
22+
.HasOne(x => x.Product)
23+
.WithMany(x => x.Reviews);
24+
}
25+
}
2626
}

0 commit comments

Comments
 (0)