EF marche enfin (même si le resutlat semble bizzare)
continuous-integration/drone/push Build is failing Details

master
Louis DUFOUR 2 years ago
parent e40792b45b
commit 21a5cfdbeb

@ -1,5 +1,7 @@
using EFlib;
using Model;
using System.Collections.Immutable;
using System.Reflection.PortableExecutable;
namespace EFMapping
{
@ -19,10 +21,11 @@ namespace EFMapping
Icon = Champ.Icon,
Class = Champ.Class,
Image = new() { Id = Guid.NewGuid(), Base64 = Champ.Image.Base64 },
Skills = Champ.Skills.Select(Skill => Skill.toEF(EfChampion, context)).ToList(),
Characteristics = Champ.Characteristics.Select(Charac => Charac.toEF(EfChampion, context)).ToList()
};
EfChampion.Skills = Champ.Skills.Select(skill => skill.toEF(EfChampion, context)).ToList();
EfChampion.Characteristics = Champ.Characteristics.Select(Charac => Charac.toEF(EfChampion, context)).ToList();
}
return EfChampion;

@ -26,13 +26,7 @@ namespace EFMapping
return EfCharacteristics;
}
public static ReadOnlyDictionary<string, int> toModel(this EFCharacteristics charac)
{
var dict = new Dictionary<string, int>
{
{ charac.Name, charac.Value }
};
return new(dict);
}
public static Tuple<string, int> toModel(this EFCharacteristics Charac)=> new(Charac.Name, Charac.Value);
}
}

@ -10,7 +10,7 @@ namespace EFMapping
{
public static class EFSkillMapper
{
public static EFSkill toEF(this Skill skill, SQLiteContext context)
public static EFSkill toEF(this Skill skill, EFChampion champ, SQLiteContext context)
{
var EfSkill = context.Skills.Find(skill.Name);
if (EfSkill == null)
@ -19,9 +19,11 @@ namespace EFMapping
{
Name = skill.Name,
Description = skill.Description,
Type = skill.Type
Type = skill.Type,
Champions = new List<EFChampion>() { champ }
};
}
EfSkill!.Champions?.Add(champ);
return EfSkill;
}
public static Skill toModel(this EFSkill skill)=> new(skill.Name, skill.Type, skill.Description);

@ -20,12 +20,12 @@ namespace EFlib
public string Icon { get; set; }
// Propriété de navigation pour les paires clé-valeur
public ICollection<EFCharacteristics> Characteristics { get; set; }
public virtual ICollection<EFCharacteristics> Characteristics { get; set; }
[Required]
public ChampionClass Class { get; set; }
public ReadOnlyCollection<EFSkin>? Skins { get; set; }
public ImmutableHashSet<EFSkill> Skills { get; set; }
public virtual ICollection<EFSkill> Skills { get; set; }
public Guid ImageId { get; set; }
[ForeignKey("ImageId")]

@ -12,8 +12,15 @@ namespace EFlib
public class EFSkill
{
[Key]
[MaxLength(250)]
public string Name { get; set; }
[Required]
[MaxLength(500)]
public string Description { get; set; }
[Required]
public SkillType Type { get; set; }
public virtual ICollection<EFChampion>? Champions { get; set; }
}
}

@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace EFlib.Migrations
{
[DbContext(typeof(SQLiteContext))]
[Migration("20230322115837_myMigration")]
[Migration("20230322184745_myMigration")]
partial class myMigration
{
/// <inheritdoc />
@ -20,6 +20,21 @@ namespace EFlib.Migrations
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EFChampionEFSkill", b =>
{
b.Property<string>("ChampionsName")
.HasColumnType("TEXT");
b.Property<string>("SkillsName")
.HasColumnType("TEXT");
b.HasKey("ChampionsName", "SkillsName");
b.HasIndex("SkillsName");
b.ToTable("EFChampionEFSkill");
});
modelBuilder.Entity("EFlib.EFChampion", b =>
{
b.Property<string>("Name")
@ -86,13 +101,12 @@ namespace EFlib.Migrations
modelBuilder.Entity("EFlib.EFSkill", b =>
{
b.Property<string>("Name")
.HasMaxLength(250)
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("EFChampionName")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("Type")
@ -100,8 +114,6 @@ namespace EFlib.Migrations
b.HasKey("Name");
b.HasIndex("EFChampionName");
b.ToTable("Skills");
});
@ -137,6 +149,21 @@ namespace EFlib.Migrations
b.ToTable("Skins");
});
modelBuilder.Entity("EFChampionEFSkill", b =>
{
b.HasOne("EFlib.EFChampion", null)
.WithMany()
.HasForeignKey("ChampionsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EFlib.EFSkill", null)
.WithMany()
.HasForeignKey("SkillsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("EFlib.EFChampion", b =>
{
b.HasOne("EFlib.EFLargeImage", "Image")
@ -159,13 +186,6 @@ namespace EFlib.Migrations
b.Navigation("Champion");
});
modelBuilder.Entity("EFlib.EFSkill", b =>
{
b.HasOne("EFlib.EFChampion", null)
.WithMany("Skills")
.HasForeignKey("EFChampionName");
});
modelBuilder.Entity("EFlib.EFSkin", b =>
{
b.HasOne("EFlib.EFLargeImage", "Image")
@ -189,8 +209,6 @@ namespace EFlib.Migrations
{
b.Navigation("Characteristics");
b.Navigation("Skills");
b.Navigation("Skins");
});
#pragma warning restore 612, 618

@ -23,6 +23,19 @@ namespace EFlib.Migrations
table.PrimaryKey("PK_LargeImages", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Skills",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", maxLength: 250, nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
Type = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Skills", x => x.Name);
});
migrationBuilder.CreateTable(
name: "Champions",
columns: table => new
@ -64,22 +77,27 @@ namespace EFlib.Migrations
});
migrationBuilder.CreateTable(
name: "Skills",
name: "EFChampionEFSkill",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
Type = table.Column<int>(type: "INTEGER", nullable: false),
EFChampionName = table.Column<string>(type: "TEXT", nullable: true)
ChampionsName = table.Column<string>(type: "TEXT", nullable: false),
SkillsName = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Skills", x => x.Name);
table.PrimaryKey("PK_EFChampionEFSkill", x => new { x.ChampionsName, x.SkillsName });
table.ForeignKey(
name: "FK_Skills_Champions_EFChampionName",
column: x => x.EFChampionName,
name: "FK_EFChampionEFSkill_Champions_ChampionsName",
column: x => x.ChampionsName,
principalTable: "Champions",
principalColumn: "Name");
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_EFChampionEFSkill_Skills_SkillsName",
column: x => x.SkillsName,
principalTable: "Skills",
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@ -121,9 +139,9 @@ namespace EFlib.Migrations
column: "NameChampion");
migrationBuilder.CreateIndex(
name: "IX_Skills_EFChampionName",
table: "Skills",
column: "EFChampionName");
name: "IX_EFChampionEFSkill_SkillsName",
table: "EFChampionEFSkill",
column: "SkillsName");
migrationBuilder.CreateIndex(
name: "IX_Skins_ImageId",
@ -143,11 +161,14 @@ namespace EFlib.Migrations
name: "Characteristics");
migrationBuilder.DropTable(
name: "Skills");
name: "EFChampionEFSkill");
migrationBuilder.DropTable(
name: "Skins");
migrationBuilder.DropTable(
name: "Skills");
migrationBuilder.DropTable(
name: "Champions");

@ -17,6 +17,21 @@ namespace EFlib.Migrations
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EFChampionEFSkill", b =>
{
b.Property<string>("ChampionsName")
.HasColumnType("TEXT");
b.Property<string>("SkillsName")
.HasColumnType("TEXT");
b.HasKey("ChampionsName", "SkillsName");
b.HasIndex("SkillsName");
b.ToTable("EFChampionEFSkill");
});
modelBuilder.Entity("EFlib.EFChampion", b =>
{
b.Property<string>("Name")
@ -83,13 +98,12 @@ namespace EFlib.Migrations
modelBuilder.Entity("EFlib.EFSkill", b =>
{
b.Property<string>("Name")
.HasMaxLength(250)
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("EFChampionName")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("Type")
@ -97,8 +111,6 @@ namespace EFlib.Migrations
b.HasKey("Name");
b.HasIndex("EFChampionName");
b.ToTable("Skills");
});
@ -134,6 +146,21 @@ namespace EFlib.Migrations
b.ToTable("Skins");
});
modelBuilder.Entity("EFChampionEFSkill", b =>
{
b.HasOne("EFlib.EFChampion", null)
.WithMany()
.HasForeignKey("ChampionsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EFlib.EFSkill", null)
.WithMany()
.HasForeignKey("SkillsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("EFlib.EFChampion", b =>
{
b.HasOne("EFlib.EFLargeImage", "Image")
@ -156,13 +183,6 @@ namespace EFlib.Migrations
b.Navigation("Champion");
});
modelBuilder.Entity("EFlib.EFSkill", b =>
{
b.HasOne("EFlib.EFChampion", null)
.WithMany("Skills")
.HasForeignKey("EFChampionName");
});
modelBuilder.Entity("EFlib.EFSkin", b =>
{
b.HasOne("EFlib.EFLargeImage", "Image")
@ -186,8 +206,6 @@ namespace EFlib.Migrations
{
b.Navigation("Characteristics");
b.Navigation("Skills");
b.Navigation("Skins");
});
#pragma warning restore 612, 618

Binary file not shown.
Loading…
Cancel
Save