From 360c84ed351f099ceb32787d35f9a56eaa5c4a2e Mon Sep 17 00:00:00 2001 From: Louison PARANT Date: Wed, 15 Mar 2023 17:25:27 +0100 Subject: [PATCH] Finished DB --- Sources/APILOL/Mapper/ChampionMapper.cs | 12 +- Sources/APILOL/Mapper/RuneMapper.cs | 17 + Sources/APILOL/Mapper/RunePageMapper.cs | 14 + Sources/APILOL/Mapper/SkinMapper.cs | 21 +- .../DBContexts/SQLiteContext.cs | 25 +- Sources/EntityFrameworkLOL/DBLOL.db | Bin 131072 -> 139264 bytes .../Entities/ChampionEntity.cs | 9 +- .../Entities/CharacteristicEntity.cs | 3 +- .../EntityFrameworkLOL/Entities/RuneEntity.cs | 2 +- .../Entities/RunePageEntity.cs | 4 +- .../Entities/RunePageRuneEntity.cs | 4 + .../EntityFrameworkLOL/Entities/SkinEntity.cs | 2 +- ...0230315161305_MigrationWallah6.Designer.cs | 374 ++++++++++++++++++ .../20230315161305_MigrationWallah6.cs | 335 ++++++++++++++++ .../Migrations/SQLiteContextModelSnapshot.cs | 371 +++++++++++++++++ Sources/EntityFrameworkLOL/Program.cs | 164 -------- Sources/ManagersEF/EFManager.Champions.cs | 5 - 17 files changed, 1171 insertions(+), 191 deletions(-) create mode 100644 Sources/EntityFrameworkLOL/Migrations/20230315161305_MigrationWallah6.Designer.cs create mode 100644 Sources/EntityFrameworkLOL/Migrations/20230315161305_MigrationWallah6.cs create mode 100644 Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs diff --git a/Sources/APILOL/Mapper/ChampionMapper.cs b/Sources/APILOL/Mapper/ChampionMapper.cs index ecd6a18..cb116d8 100644 --- a/Sources/APILOL/Mapper/ChampionMapper.cs +++ b/Sources/APILOL/Mapper/ChampionMapper.cs @@ -25,9 +25,14 @@ namespace APILOL.Mapper return new Champion(champion.Name, champion.Class, champion.Icon, champion.Image.ToString(), champion.Bio); } + public static Champion ToModel(this ChampionEntity entity) + { + return new Champion(entity.Name, entity.Class, entity.Icon, entity.Image.Base64, entity.Bio); + } + public static ChampionEntity ToEntity(this Champion item) { - return new() + return new ChampionEntity { Name = item.Name, Bio = item.Bio, @@ -36,10 +41,5 @@ namespace APILOL.Mapper Image = new() { Base64 = item.Image.Base64 }, }; } - - public static Champion ToModel(this ChampionEntity entity) - { - return new(entity.Name, entity.Class, entity.Icon, entity.Image.Base64, entity.Bio); - } } } \ No newline at end of file diff --git a/Sources/APILOL/Mapper/RuneMapper.cs b/Sources/APILOL/Mapper/RuneMapper.cs index e1a582b..a3d3d78 100644 --- a/Sources/APILOL/Mapper/RuneMapper.cs +++ b/Sources/APILOL/Mapper/RuneMapper.cs @@ -1,4 +1,5 @@ using DTO; +using EntityFrameworkLOL.Entities; using Model; namespace APILOL.Mapper @@ -20,5 +21,21 @@ namespace APILOL.Mapper { return new Rune(rune.Name, rune.Family, rune.Image, rune.Image, rune.Description); } + + public static Rune ToModel(this RuneEntity entity) + { + return new Rune(entity.Name, entity.Family, "", entity.Image.Base64, entity.Description); + } + + public static RuneEntity ToEntity(this Rune item) + { + return new RuneEntity + { + Name = item.Name, + Description = item.Description, + Image = new() { Base64 = item.Image.Base64 }, + Family = item.Family, + }; + } } } diff --git a/Sources/APILOL/Mapper/RunePageMapper.cs b/Sources/APILOL/Mapper/RunePageMapper.cs index 6bc4de2..62d934f 100644 --- a/Sources/APILOL/Mapper/RunePageMapper.cs +++ b/Sources/APILOL/Mapper/RunePageMapper.cs @@ -1,4 +1,5 @@ using DTO; +using EntityFrameworkLOL.Entities; using Model; namespace APILOL.Mapper @@ -18,5 +19,18 @@ namespace APILOL.Mapper { return new RunePage(runePage.Name); } + + public static RunePage ToModel(this RunePageEntity entity) + { + return new RunePage(entity.Name); + } + + public static RunePageEntity ToEntity(this RunePage item) + { + return new RunePageEntity + { + Name = item.Name, + }; + } } } diff --git a/Sources/APILOL/Mapper/SkinMapper.cs b/Sources/APILOL/Mapper/SkinMapper.cs index 7fc1a2c..941ca37 100644 --- a/Sources/APILOL/Mapper/SkinMapper.cs +++ b/Sources/APILOL/Mapper/SkinMapper.cs @@ -1,4 +1,5 @@ using DTO; +using EntityFrameworkLOL.Entities; using Model; namespace APILOL.Mapper @@ -22,5 +23,23 @@ namespace APILOL.Mapper { return new Skin(skin.Name, skin.Champion.ToModel(),skin.Price, skin.Image, skin.Icon, skin.Description); } + + public static Skin ToModel(this SkinEntity entity) + { + return new Skin(entity.Name, entity.ChampionSkin.ToModel(), entity.Price, entity.Icon, entity.Description); + } + + public static SkinEntity ToEntity(this Skin item) + { + return new SkinEntity + { + Name = item.Name, + Description = item.Description, + Icon = item.Icon, + Price = item.Price, + ChampionSkin = item.Champion.ToEntity(), + Image = new() { Base64 = item.Image.Base64 }, + }; + } } -} +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs b/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs index 8d9ad94..587ec70 100644 --- a/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs +++ b/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs @@ -1,5 +1,7 @@ using EntityFrameworkLOL.Entities; +using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Options; using Model; namespace EntityFrameworkLOL.DBContexts @@ -11,20 +13,30 @@ namespace EntityFrameworkLOL.DBContexts public DbSet Skin { get; set; } public DbSet Rune { get; set; } public DbSet RunePage { get; set; } + public DbSet Characteristic { get; set; } public DbSet Champion { get; set; } + public SQLiteContext() { } + + public SQLiteContext(DbContextOptions options) + : base(options) + { } + protected override void OnConfiguring(DbContextOptionsBuilder options) - => options.UseSqlite($"Data Source=DBLOL.db"); + { + //var connection = new SqliteConnection("DataSource=:memory:"); + var connection = new SqliteConnection("Data Source=DBLOL.db"); + connection.Open(); + options.UseSqlite(connection); + } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().Property(i => i.Base64).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasKey(c => new { c.Name, c.Champion }); + modelBuilder.Entity().HasKey(c => new { c.Name }); modelBuilder.Entity().Property(rp => rp.Name).ValueGeneratedOnAdd(); modelBuilder.Entity() - .HasMany(rp => rp.Runes) - .WithMany(r => r.RunePages) - .UsingEntity(); + .HasMany(rp => rp.Runes); modelBuilder.Entity() .HasMany(c => c.RunePages) .WithMany(rp => rp.Champions); @@ -41,13 +53,14 @@ namespace EntityFrameworkLOL.DBContexts Name = "WinKer", Bio = "Best front-end designer", Class = ChampionClass.Mage, - + Icon = "", }, new() { Name = "Jonquille", Bio = "Daffodil", Class = ChampionClass.Support, + Icon = "", } }); modelBuilder.Entity().HasData(new List() { diff --git a/Sources/EntityFrameworkLOL/DBLOL.db b/Sources/EntityFrameworkLOL/DBLOL.db index 5ecb42a6c875dcf189120666a1dad7dc6c9d7131..a3995b7b5a3b4b5c835f78020b3c66b54dc5684a 100644 GIT binary patch delta 4468 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 Skills { get; set; } - public virtual ICollection Characteristics { get; set; } + //public virtual ICollection Characteristics { get; set; } - public ICollection RunePages { get; set; } + public virtual ICollection RunePages { get; set; } } } \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/CharacteristicEntity.cs b/Sources/EntityFrameworkLOL/Entities/CharacteristicEntity.cs index 7c7da71..ca87641 100644 --- a/Sources/EntityFrameworkLOL/Entities/CharacteristicEntity.cs +++ b/Sources/EntityFrameworkLOL/Entities/CharacteristicEntity.cs @@ -17,7 +17,8 @@ namespace EntityFrameworkLOL.Entities [Required] public int Value { get; set; } - [ForeignKey("ChampionEntity")] public ChampionEntity Champion { get; set; } + + //public virtual ICollection Champions { get; set; } } } \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs b/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs index 83bef82..4340ca3 100644 --- a/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs +++ b/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs @@ -21,6 +21,6 @@ namespace EntityFrameworkLOL.Entities [Required] public RuneFamily Family { get; set; } - public ICollection RunePages { get; set; } + public virtual ICollection RunePages { get; set; } } } \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/RunePageEntity.cs b/Sources/EntityFrameworkLOL/Entities/RunePageEntity.cs index 6c30ddf..028bfe5 100644 --- a/Sources/EntityFrameworkLOL/Entities/RunePageEntity.cs +++ b/Sources/EntityFrameworkLOL/Entities/RunePageEntity.cs @@ -20,8 +20,8 @@ namespace EntityFrameworkLOL.Entities [Key] public string Name { get; set; } - public ICollection Runes { get; set; } + public virtual ICollection Runes { get; set; } - public ICollection Champions { get; set; } + public virtual ICollection Champions { get; set; } } } \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/RunePageRuneEntity.cs b/Sources/EntityFrameworkLOL/Entities/RunePageRuneEntity.cs index 02e256d..3bf8800 100644 --- a/Sources/EntityFrameworkLOL/Entities/RunePageRuneEntity.cs +++ b/Sources/EntityFrameworkLOL/Entities/RunePageRuneEntity.cs @@ -11,5 +11,9 @@ namespace EntityFrameworkLOL.Entities public class RunePageRuneEntity { public Category Category { get; set; } + + public RuneEntity Rune { get; set; } + + public RunePageEntity RunePage { get; set; } } } \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/SkinEntity.cs b/Sources/EntityFrameworkLOL/Entities/SkinEntity.cs index eb6496e..05954a1 100644 --- a/Sources/EntityFrameworkLOL/Entities/SkinEntity.cs +++ b/Sources/EntityFrameworkLOL/Entities/SkinEntity.cs @@ -15,7 +15,7 @@ namespace EntityFrameworkLOL.Entities public string Description { get; set; } - public string Icon { get; set; } + public string? Icon { get; set; } public float Price { get; set; } diff --git a/Sources/EntityFrameworkLOL/Migrations/20230315161305_MigrationWallah6.Designer.cs b/Sources/EntityFrameworkLOL/Migrations/20230315161305_MigrationWallah6.Designer.cs new file mode 100644 index 0000000..6dd9313 --- /dev/null +++ b/Sources/EntityFrameworkLOL/Migrations/20230315161305_MigrationWallah6.Designer.cs @@ -0,0 +1,374 @@ +// +using EntityFrameworkLOL.DBContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFrameworkLOL.Migrations +{ + [DbContext(typeof(SQLiteContext))] + [Migration("20230315161305_MigrationWallah6")] + partial class MigrationWallah6 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("ChampionEntityRunePageEntity", b => + { + b.Property("ChampionsName") + .HasColumnType("TEXT"); + + b.Property("RunePagesName") + .HasColumnType("TEXT"); + + b.HasKey("ChampionsName", "RunePagesName"); + + b.HasIndex("RunePagesName"); + + b.ToTable("ChampionEntityRunePageEntity"); + }); + + modelBuilder.Entity("ChampionEntitySkillEntity", b => + { + b.Property("ChampionsName") + .HasColumnType("TEXT"); + + b.Property("SkillsName") + .HasColumnType("TEXT"); + + b.HasKey("ChampionsName", "SkillsName"); + + b.HasIndex("SkillsName"); + + b.ToTable("ChampionEntitySkillEntity"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Bio") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Class") + .HasColumnType("INTEGER"); + + b.Property("Icon") + .HasColumnType("TEXT"); + + b.Property("ImageBase64") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex("ImageBase64"); + + b.ToTable("Champion"); + + b.HasData( + new + { + Name = "WinKer", + Bio = "Best front-end designer", + Class = 3, + Icon = "" + }, + new + { + Name = "Jonquille", + Bio = "Daffodil", + Class = 5, + Icon = "" + }); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.CharacteristicEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("ChampionName") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("Name"); + + b.HasIndex("ChampionName"); + + b.ToTable("Characteristic"); + + b.HasData( + new + { + Name = "Front-end", + Value = 100 + }, + new + { + Name = "Back-end", + Value = 100 + }); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ImageEntity", b => + { + b.Property("Base64") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.HasKey("Base64"); + + b.ToTable("Image"); + + b.HasData( + new + { + Base64 = "default" + }); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Family") + .HasColumnType("INTEGER"); + + b.Property("ImageBase64") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex("ImageBase64"); + + b.ToTable("Rune"); + + b.HasData( + new + { + Name = "Mastering of Blue", + Description = "Blue shades", + Family = 2 + }, + new + { + Name = "Empty Shards", + Description = "Remove runes", + Family = 1 + }); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RunePageEntity", b => + { + b.Property("Name") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("RunePage"); + + b.HasData( + new + { + Name = "FirstRunepage" + }); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkillEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Name"); + + b.ToTable("Skill"); + + b.HasData( + new + { + Name = "Beautiful layout", + Description = "Bowl'In", + Type = 3 + }, + new + { + Name = "DB Support", + Description = "DB", + Type = 1 + }); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("ChampionSkinName") + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Icon") + .HasColumnType("TEXT"); + + b.Property("ImageBase64") + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("REAL"); + + b.HasKey("Name"); + + b.HasIndex("ChampionSkinName"); + + b.HasIndex("ImageBase64"); + + b.ToTable("Skin"); + + b.HasData( + new + { + Name = "Darker WinKer", + Description = "Be invisible in the darkness but never alone", + Icon = "default", + Price = 9.99f + }, + new + { + Name = "Summer Daffodil", + Description = "A jewel of Summer for all year long", + Icon = "default", + Price = 9.99f + }); + }); + + modelBuilder.Entity("RuneEntityRunePageEntity", b => + { + b.Property("RunePagesName") + .HasColumnType("TEXT"); + + b.Property("RunesName") + .HasColumnType("TEXT"); + + b.HasKey("RunePagesName", "RunesName"); + + b.HasIndex("RunesName"); + + b.ToTable("RuneEntityRunePageEntity"); + }); + + modelBuilder.Entity("ChampionEntityRunePageEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", null) + .WithMany() + .HasForeignKey("ChampionsName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameworkLOL.Entities.RunePageEntity", null) + .WithMany() + .HasForeignKey("RunePagesName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ChampionEntitySkillEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", null) + .WithMany() + .HasForeignKey("ChampionsName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameworkLOL.Entities.SkillEntity", null) + .WithMany() + .HasForeignKey("SkillsName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageBase64"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.CharacteristicEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "Champion") + .WithMany() + .HasForeignKey("ChampionName"); + + b.Navigation("Champion"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageBase64"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "ChampionSkin") + .WithMany() + .HasForeignKey("ChampionSkinName"); + + b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageBase64"); + + b.Navigation("ChampionSkin"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("RuneEntityRunePageEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.RunePageEntity", null) + .WithMany() + .HasForeignKey("RunePagesName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameworkLOL.Entities.RuneEntity", null) + .WithMany() + .HasForeignKey("RunesName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/EntityFrameworkLOL/Migrations/20230315161305_MigrationWallah6.cs b/Sources/EntityFrameworkLOL/Migrations/20230315161305_MigrationWallah6.cs new file mode 100644 index 0000000..5d59d7b --- /dev/null +++ b/Sources/EntityFrameworkLOL/Migrations/20230315161305_MigrationWallah6.cs @@ -0,0 +1,335 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace EntityFrameworkLOL.Migrations +{ + /// + public partial class MigrationWallah6 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Image", + columns: table => new + { + Base64 = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Image", x => x.Base64); + }); + + migrationBuilder.CreateTable( + name: "RunePage", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RunePage", x => x.Name); + }); + + migrationBuilder.CreateTable( + name: "Skill", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false), + Description = table.Column(type: "TEXT", nullable: false), + Type = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Skill", x => x.Name); + }); + + migrationBuilder.CreateTable( + name: "Champion", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false), + Bio = table.Column(type: "TEXT", nullable: false), + Icon = table.Column(type: "TEXT", nullable: true), + Class = table.Column(type: "INTEGER", nullable: false), + ImageBase64 = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Champion", x => x.Name); + table.ForeignKey( + name: "FK_Champion_Image_ImageBase64", + column: x => x.ImageBase64, + principalTable: "Image", + principalColumn: "Base64"); + }); + + migrationBuilder.CreateTable( + name: "Rune", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false), + Description = table.Column(type: "TEXT", nullable: false), + ImageBase64 = table.Column(type: "TEXT", nullable: true), + Family = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Rune", x => x.Name); + table.ForeignKey( + name: "FK_Rune_Image_ImageBase64", + column: x => x.ImageBase64, + principalTable: "Image", + principalColumn: "Base64"); + }); + + migrationBuilder.CreateTable( + name: "ChampionEntityRunePageEntity", + columns: table => new + { + ChampionsName = table.Column(type: "TEXT", nullable: false), + RunePagesName = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ChampionEntityRunePageEntity", x => new { x.ChampionsName, x.RunePagesName }); + table.ForeignKey( + name: "FK_ChampionEntityRunePageEntity_Champion_ChampionsName", + column: x => x.ChampionsName, + principalTable: "Champion", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ChampionEntityRunePageEntity_RunePage_RunePagesName", + column: x => x.RunePagesName, + principalTable: "RunePage", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ChampionEntitySkillEntity", + columns: table => new + { + ChampionsName = table.Column(type: "TEXT", nullable: false), + SkillsName = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ChampionEntitySkillEntity", x => new { x.ChampionsName, x.SkillsName }); + table.ForeignKey( + name: "FK_ChampionEntitySkillEntity_Champion_ChampionsName", + column: x => x.ChampionsName, + principalTable: "Champion", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ChampionEntitySkillEntity_Skill_SkillsName", + column: x => x.SkillsName, + principalTable: "Skill", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Characteristic", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false), + Value = table.Column(type: "INTEGER", nullable: false), + ChampionName = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Characteristic", x => x.Name); + table.ForeignKey( + name: "FK_Characteristic_Champion_ChampionName", + column: x => x.ChampionName, + principalTable: "Champion", + principalColumn: "Name"); + }); + + migrationBuilder.CreateTable( + name: "Skin", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false), + Description = table.Column(type: "TEXT", nullable: false), + Icon = table.Column(type: "TEXT", nullable: true), + Price = table.Column(type: "REAL", nullable: false), + ImageBase64 = table.Column(type: "TEXT", nullable: true), + ChampionSkinName = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Skin", x => x.Name); + table.ForeignKey( + name: "FK_Skin_Champion_ChampionSkinName", + column: x => x.ChampionSkinName, + principalTable: "Champion", + principalColumn: "Name"); + table.ForeignKey( + name: "FK_Skin_Image_ImageBase64", + column: x => x.ImageBase64, + principalTable: "Image", + principalColumn: "Base64"); + }); + + migrationBuilder.CreateTable( + name: "RuneEntityRunePageEntity", + columns: table => new + { + RunePagesName = table.Column(type: "TEXT", nullable: false), + RunesName = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RuneEntityRunePageEntity", x => new { x.RunePagesName, x.RunesName }); + table.ForeignKey( + name: "FK_RuneEntityRunePageEntity_RunePage_RunePagesName", + column: x => x.RunePagesName, + principalTable: "RunePage", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RuneEntityRunePageEntity_Rune_RunesName", + column: x => x.RunesName, + principalTable: "Rune", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.InsertData( + table: "Champion", + columns: new[] { "Name", "Bio", "Class", "Icon", "ImageBase64" }, + values: new object[,] + { + { "Jonquille", "Daffodil", 5, "", null }, + { "WinKer", "Best front-end designer", 3, "", null } + }); + + migrationBuilder.InsertData( + table: "Characteristic", + columns: new[] { "Name", "ChampionName", "Value" }, + values: new object[,] + { + { "Back-end", null, 100 }, + { "Front-end", null, 100 } + }); + + migrationBuilder.InsertData( + table: "Image", + column: "Base64", + value: "default"); + + migrationBuilder.InsertData( + table: "Rune", + columns: new[] { "Name", "Description", "Family", "ImageBase64" }, + values: new object[,] + { + { "Empty Shards", "Remove runes", 1, null }, + { "Mastering of Blue", "Blue shades", 2, null } + }); + + migrationBuilder.InsertData( + table: "RunePage", + column: "Name", + value: "FirstRunepage"); + + migrationBuilder.InsertData( + table: "Skill", + columns: new[] { "Name", "Description", "Type" }, + values: new object[,] + { + { "Beautiful layout", "Bowl'In", 3 }, + { "DB Support", "DB", 1 } + }); + + migrationBuilder.InsertData( + table: "Skin", + columns: new[] { "Name", "ChampionSkinName", "Description", "Icon", "ImageBase64", "Price" }, + values: new object[,] + { + { "Darker WinKer", null, "Be invisible in the darkness but never alone", "default", null, 9.99f }, + { "Summer Daffodil", null, "A jewel of Summer for all year long", "default", null, 9.99f } + }); + + migrationBuilder.CreateIndex( + name: "IX_Champion_ImageBase64", + table: "Champion", + column: "ImageBase64"); + + migrationBuilder.CreateIndex( + name: "IX_ChampionEntityRunePageEntity_RunePagesName", + table: "ChampionEntityRunePageEntity", + column: "RunePagesName"); + + migrationBuilder.CreateIndex( + name: "IX_ChampionEntitySkillEntity_SkillsName", + table: "ChampionEntitySkillEntity", + column: "SkillsName"); + + migrationBuilder.CreateIndex( + name: "IX_Characteristic_ChampionName", + table: "Characteristic", + column: "ChampionName"); + + migrationBuilder.CreateIndex( + name: "IX_Rune_ImageBase64", + table: "Rune", + column: "ImageBase64"); + + migrationBuilder.CreateIndex( + name: "IX_RuneEntityRunePageEntity_RunesName", + table: "RuneEntityRunePageEntity", + column: "RunesName"); + + migrationBuilder.CreateIndex( + name: "IX_Skin_ChampionSkinName", + table: "Skin", + column: "ChampionSkinName"); + + migrationBuilder.CreateIndex( + name: "IX_Skin_ImageBase64", + table: "Skin", + column: "ImageBase64"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ChampionEntityRunePageEntity"); + + migrationBuilder.DropTable( + name: "ChampionEntitySkillEntity"); + + migrationBuilder.DropTable( + name: "Characteristic"); + + migrationBuilder.DropTable( + name: "RuneEntityRunePageEntity"); + + migrationBuilder.DropTable( + name: "Skin"); + + migrationBuilder.DropTable( + name: "Skill"); + + migrationBuilder.DropTable( + name: "RunePage"); + + migrationBuilder.DropTable( + name: "Rune"); + + migrationBuilder.DropTable( + name: "Champion"); + + migrationBuilder.DropTable( + name: "Image"); + } + } +} diff --git a/Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs b/Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs new file mode 100644 index 0000000..cc7759d --- /dev/null +++ b/Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs @@ -0,0 +1,371 @@ +// +using EntityFrameworkLOL.DBContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFrameworkLOL.Migrations +{ + [DbContext(typeof(SQLiteContext))] + partial class SQLiteContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("ChampionEntityRunePageEntity", b => + { + b.Property("ChampionsName") + .HasColumnType("TEXT"); + + b.Property("RunePagesName") + .HasColumnType("TEXT"); + + b.HasKey("ChampionsName", "RunePagesName"); + + b.HasIndex("RunePagesName"); + + b.ToTable("ChampionEntityRunePageEntity"); + }); + + modelBuilder.Entity("ChampionEntitySkillEntity", b => + { + b.Property("ChampionsName") + .HasColumnType("TEXT"); + + b.Property("SkillsName") + .HasColumnType("TEXT"); + + b.HasKey("ChampionsName", "SkillsName"); + + b.HasIndex("SkillsName"); + + b.ToTable("ChampionEntitySkillEntity"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Bio") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Class") + .HasColumnType("INTEGER"); + + b.Property("Icon") + .HasColumnType("TEXT"); + + b.Property("ImageBase64") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex("ImageBase64"); + + b.ToTable("Champion"); + + b.HasData( + new + { + Name = "WinKer", + Bio = "Best front-end designer", + Class = 3, + Icon = "" + }, + new + { + Name = "Jonquille", + Bio = "Daffodil", + Class = 5, + Icon = "" + }); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.CharacteristicEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("ChampionName") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("Name"); + + b.HasIndex("ChampionName"); + + b.ToTable("Characteristic"); + + b.HasData( + new + { + Name = "Front-end", + Value = 100 + }, + new + { + Name = "Back-end", + Value = 100 + }); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ImageEntity", b => + { + b.Property("Base64") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.HasKey("Base64"); + + b.ToTable("Image"); + + b.HasData( + new + { + Base64 = "default" + }); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Family") + .HasColumnType("INTEGER"); + + b.Property("ImageBase64") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex("ImageBase64"); + + b.ToTable("Rune"); + + b.HasData( + new + { + Name = "Mastering of Blue", + Description = "Blue shades", + Family = 2 + }, + new + { + Name = "Empty Shards", + Description = "Remove runes", + Family = 1 + }); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RunePageEntity", b => + { + b.Property("Name") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("RunePage"); + + b.HasData( + new + { + Name = "FirstRunepage" + }); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkillEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Name"); + + b.ToTable("Skill"); + + b.HasData( + new + { + Name = "Beautiful layout", + Description = "Bowl'In", + Type = 3 + }, + new + { + Name = "DB Support", + Description = "DB", + Type = 1 + }); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("ChampionSkinName") + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Icon") + .HasColumnType("TEXT"); + + b.Property("ImageBase64") + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("REAL"); + + b.HasKey("Name"); + + b.HasIndex("ChampionSkinName"); + + b.HasIndex("ImageBase64"); + + b.ToTable("Skin"); + + b.HasData( + new + { + Name = "Darker WinKer", + Description = "Be invisible in the darkness but never alone", + Icon = "default", + Price = 9.99f + }, + new + { + Name = "Summer Daffodil", + Description = "A jewel of Summer for all year long", + Icon = "default", + Price = 9.99f + }); + }); + + modelBuilder.Entity("RuneEntityRunePageEntity", b => + { + b.Property("RunePagesName") + .HasColumnType("TEXT"); + + b.Property("RunesName") + .HasColumnType("TEXT"); + + b.HasKey("RunePagesName", "RunesName"); + + b.HasIndex("RunesName"); + + b.ToTable("RuneEntityRunePageEntity"); + }); + + modelBuilder.Entity("ChampionEntityRunePageEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", null) + .WithMany() + .HasForeignKey("ChampionsName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameworkLOL.Entities.RunePageEntity", null) + .WithMany() + .HasForeignKey("RunePagesName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ChampionEntitySkillEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", null) + .WithMany() + .HasForeignKey("ChampionsName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameworkLOL.Entities.SkillEntity", null) + .WithMany() + .HasForeignKey("SkillsName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageBase64"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.CharacteristicEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "Champion") + .WithMany() + .HasForeignKey("ChampionName"); + + b.Navigation("Champion"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageBase64"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "ChampionSkin") + .WithMany() + .HasForeignKey("ChampionSkinName"); + + b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageBase64"); + + b.Navigation("ChampionSkin"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("RuneEntityRunePageEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.RunePageEntity", null) + .WithMany() + .HasForeignKey("RunePagesName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameworkLOL.Entities.RuneEntity", null) + .WithMany() + .HasForeignKey("RunesName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/EntityFrameworkLOL/Program.cs b/Sources/EntityFrameworkLOL/Program.cs index 07c35d6..4fbb5ba 100644 --- a/Sources/EntityFrameworkLOL/Program.cs +++ b/Sources/EntityFrameworkLOL/Program.cs @@ -8,169 +8,5 @@ class Program { static void Main(string[] args) { - using (var context = new SQLiteContext()) { - if (context.Champion.Count() > 0) - { - foreach (var c in context.Champion.ToArray()) - { - context.Champion.Remove(c); - } - } - if (context.Rune.Count() > 0) - { - foreach (var r in context.Rune.ToArray()) - { - context.Rune.Remove(r); - } - } - if (context.Skin.Count() > 0) - { - foreach (var s in context.Skin.ToArray()) - { - context.Skin.Remove(s); - } - } - if (context.Skill.Count() > 0) - { - foreach (var s in context.Skill.ToArray()) - { - context.Skill.Remove(s); - } - } - if (context.RunePage.Count() > 0) - { - foreach (var rp in context.RunePage.ToArray()) - { - context.RunePage.Remove(rp); - } - } - if (context.ChampionClass.Count() > 0) - { - foreach (var cc in context.ChampionClass.ToArray()) - { - context.ChampionClass.Remove(cc); - } - } - if (context.RuneFamily.Count() > 0) - { - foreach (var rf in context.RuneFamily.ToArray()) - { - context.RuneFamily.Remove(rf); - } - } - if (context.SkillType.Count() > 0) - { - foreach (var st in context.SkillType.ToArray()) - { - context.SkillType.Remove(st); - } - } - if (context.Image.Count() > 0) - { - foreach (var i in context.Image.ToArray()) - { - context.Image.Remove(i); - } - } - context.SaveChanges(); - } - ChampionEntity akali = new ChampionEntity { Name = "Akali", Bio = "" }; - ChampionEntity aatrox = new ChampionEntity { Name = "Aatrox", Bio = "" }; - ChampionEntity ahri = new ChampionEntity { Name = "Ahri", Bio = "" }; - ChampionEntity bard = new ChampionEntity { Name = "Bard", Bio = "" }; - ChampionEntity alistar = new ChampionEntity { Name = "Alistar", Bio = "" }; - ChampionEntity akshan = new ChampionEntity { Name = "Akshan", Bio = "" }; - - using (var context = new SQLiteContext()) - { - // Crée des champions et les insère dans la base - Console.WriteLine("Creates and inserts new Champions"); - context.AddRange(new ChampionEntity[] { akali, aatrox, ahri, bard, alistar, akshan }); - /*context.Add(akali); - context.Add(aatrox); - context.Add(ahri); - context.Add(bard); - context.Add(alistar); - context.Add(akshan);*/ - context.SaveChanges(); - Console.WriteLine("Creates and executes a query retrieving the first Champion of the database whose name starts with an \"A\":"); - var aChampion = context.Champion - .Where(c => c.Name.StartsWith("A")) - .First(); - Console.WriteLine($"{aChampion.Name} (with bio : \"{aChampion.Bio}\")"); - } - - RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "" }; - RuneEntity thriumph = new RuneEntity { Name = "Thriumph", Description = "" }; - RuneEntity alacrity = new RuneEntity { Name = "Legend : Alacrity", Description = "" }; - RuneEntity tenacity = new RuneEntity { Name = "Legend : Tenacity", Description = "" }; - RuneEntity laststand = new RuneEntity { Name = "Last Stand", Description = "" }; - RuneEntity laststand2 = new RuneEntity { Name = "Last Stand 2", Description = "" }; - - using (var context = new SQLiteContext()) - { - // Crée des Runes et les insère dans la base - Console.WriteLine("Creates and inserts new Runes"); - context.AddRange(new RuneEntity[] { conqueror, thriumph, alacrity, tenacity, laststand, laststand2 }); - /*context.Add(conqueror); - context.Add(thriumph); - context.Add(alacrity); - context.Add(tenacity); - context.Add(laststand); - context.Add(laststand2);*/ - context.SaveChanges(); - Console.WriteLine("Creates and executes a query retrieving the first Runes of the database whose name starts with an \"L\":"); - var lRune = context.Rune - .Where(r => r.Name.StartsWith("L")) - .First(); - Console.WriteLine($"{lRune.Name} (with Description : \"{lRune.Description}\")"); - } - - SkinEntity stinger = new SkinEntity { Name = "Stinger", Description = "" }; - SkinEntity infernal = new SkinEntity { Name = "Infernal", Description = "" }; - SkinEntity allStar = new SkinEntity { Name = "All-Star", Description = "" }; - SkinEntity justicar = new SkinEntity { Name = "Justicar", Description = "" }; - SkinEntity mecha = new SkinEntity { Name = "Mecha", Description = "" }; - SkinEntity seaHunter = new SkinEntity { Name = "Sea Hunter", Description = "" }; - - using (var context = new SQLiteContext()) - { - // Crée des Skins et les insère dans la base - Console.WriteLine("Creates and inserts new Skins"); - context.AddRange(new SkinEntity[] { stinger, infernal, allStar, justicar, mecha, seaHunter }); - /*context.Add(stinger); - context.Add(infernal); - context.Add(allStar); - context.Add(justicar); - context.Add(mecha); - context.Add(seaHunter);*/ - context.SaveChanges(); - Console.WriteLine("Creates and executes a query retrieving the first Skins of the database whose name starts with an \"I\":"); - var iSkin = context.Skin - .Where(s => s.Name.StartsWith("I")) - .First(); - Console.WriteLine($"{iSkin.Name} (with Description : \"{iSkin.Description}\")"); - - Console.WriteLine("Updates the name of the Infernal Skin"); - iSkin.Description = "Hella Infernal (Wallah)"; - context.SaveChanges(); - Console.WriteLine($"{iSkin.Name} (with Description : \"{iSkin.Description}\")"); - - Console.WriteLine("Deletes one item from the database"); - var droid = context.Skin - .SingleOrDefault(s => s.Name.Equals("Infernal")); - context.Remove(droid); - context.SaveChanges(); - } - - using (var context = new SQLiteContext()) - { - foreach (var c in context.Champion) - { - c.Bio = $"{c.Name}"; - Console.WriteLine($"{c.Name} - {c.Bio}"); - } - context.SaveChanges(); - } } } \ No newline at end of file diff --git a/Sources/ManagersEF/EFManager.Champions.cs b/Sources/ManagersEF/EFManager.Champions.cs index 8e4b040..7dc361c 100644 --- a/Sources/ManagersEF/EFManager.Champions.cs +++ b/Sources/ManagersEF/EFManager.Champions.cs @@ -36,11 +36,6 @@ namespace ManagersEF public async Task> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false) { - - return parent.DbContext.Champion.GetItemsWithFilterAndOrdering( - c => c.Characteristics.Any(ch => ch.Name.Equals(charName)), - index, count, - orderingPropertyName, descending).Select(c => c.ToModel()); } public async Task> GetItemsByClass(ChampionClass championClass, int index, int count, string? orderingPropertyName = null, bool descending = false)