diff --git a/Sources/EFLol/ChampionEntity.cs b/Sources/EFLol/ChampionEntity.cs index b23a534..7cdd4da 100644 --- a/Sources/EFLol/ChampionEntity.cs +++ b/Sources/EFLol/ChampionEntity.cs @@ -18,6 +18,6 @@ namespace EFLol //public LargeImage Image { get; set; } //public ReadOnlyDictionary Characteristics { get; private set; } //private HashSet skills = new HashSet(); - public ReadOnlyCollection Skins { get; set; } + public Collection Skins { get; set; } } } diff --git a/Sources/EFLol/MyDbContext.cs b/Sources/EFLol/MyDbContext.cs index 17ad759..8735e18 100644 --- a/Sources/EFLol/MyDbContext.cs +++ b/Sources/EFLol/MyDbContext.cs @@ -11,6 +11,7 @@ namespace EFLol { public DbSet Champions { get; set; } public DbSet Skins { get; set; } + public DbSet Runes { get; set; } public MyDbContext() { } @@ -32,6 +33,7 @@ namespace EFLol base.OnModelCreating(modelBuilder); modelBuilder.Entity().Property(c => c.Id).ValueGeneratedOnAdd(); modelBuilder.Entity().Property(s => s.Id).ValueGeneratedOnAdd(); + } } } diff --git a/Sources/EFLol/Program.cs b/Sources/EFLol/Program.cs index fbac836..a7a69de 100644 --- a/Sources/EFLol/Program.cs +++ b/Sources/EFLol/Program.cs @@ -18,14 +18,14 @@ ChampionEntity Zeus = new ChampionEntity { Name = "Zeus", Bio = "Zeus is the god of the sky", - Skins = new ReadOnlyCollection(new List { black, white }) + Skins = new Collection(new List { black, white }) }; ChampionEntity Hera = new ChampionEntity { Name = "Hera", Bio = "Hera is the goddess of marriage", - Skins = new ReadOnlyCollection(new List { green }) + Skins = new Collection(new List { green }) }; ChampionEntity Poseidon = new ChampionEntity { Name = "Poseidon", Bio = "Poseidon is the god of the sea" }; @@ -34,7 +34,6 @@ ChampionEntity Poseidon = new ChampionEntity { Name = "Poseidon", Bio = "Poseido using (var context = new MyDbContext()) { - // Crée des champions et les insère dans la base Console.WriteLine("Creates and inserts new Champions"); context.Add(Zeus); context.Add(Hera); @@ -47,12 +46,11 @@ using (var context = new MyDbContext()) { foreach (var n in context.Champions) { - // Use LINQ to display the skins for each champion - var skins = from s in context.Skins - where n.Id == s.Id - select s; + // LINQ to select the skins of the current champion + var skins = context.Champions.Where(c => c.Id == n.Id).SelectMany(c => c.Skins); - Console.WriteLine($"Champion n°{n.Id} - {n.Name}"); + // Display the champion and its skins + Console.WriteLine($"Champion n°{n.Id} - {n.Name} : {skins.Count()} skins"); } context.SaveChanges(); } diff --git a/Sources/EFLol/RuneEntity.cs b/Sources/EFLol/RuneEntity.cs new file mode 100644 index 0000000..3f099dc --- /dev/null +++ b/Sources/EFLol/RuneEntity.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EFLol +{ + public class RuneEntity + { + public int Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + //public RuneFamily Family { get; set; } + //public string Icon { get; set; } + //public string Image { get; set; } + + } +}