|
|
@ -18,14 +18,14 @@ ChampionEntity Zeus = new ChampionEntity
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Name = "Zeus",
|
|
|
|
Name = "Zeus",
|
|
|
|
Bio = "Zeus is the god of the sky",
|
|
|
|
Bio = "Zeus is the god of the sky",
|
|
|
|
Skins = new ReadOnlyCollection<SkinEntity>(new List<SkinEntity> { black, white })
|
|
|
|
Skins = new Collection<SkinEntity>(new List<SkinEntity> { black, white })
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
ChampionEntity Hera = new ChampionEntity
|
|
|
|
ChampionEntity Hera = new ChampionEntity
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Name = "Hera",
|
|
|
|
Name = "Hera",
|
|
|
|
Bio = "Hera is the goddess of marriage",
|
|
|
|
Bio = "Hera is the goddess of marriage",
|
|
|
|
Skins = new ReadOnlyCollection<SkinEntity>(new List<SkinEntity> { green })
|
|
|
|
Skins = new Collection<SkinEntity>(new List<SkinEntity> { green })
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
ChampionEntity Poseidon = new ChampionEntity { Name = "Poseidon", Bio = "Poseidon is the god of the sea" };
|
|
|
|
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())
|
|
|
|
using (var context = new MyDbContext())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Crée des champions et les insère dans la base
|
|
|
|
|
|
|
|
Console.WriteLine("Creates and inserts new Champions");
|
|
|
|
Console.WriteLine("Creates and inserts new Champions");
|
|
|
|
context.Add(Zeus);
|
|
|
|
context.Add(Zeus);
|
|
|
|
context.Add(Hera);
|
|
|
|
context.Add(Hera);
|
|
|
@ -47,12 +46,11 @@ using (var context = new MyDbContext())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach (var n in context.Champions)
|
|
|
|
foreach (var n in context.Champions)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Use LINQ to display the skins for each champion
|
|
|
|
// LINQ to select the skins of the current champion
|
|
|
|
var skins = from s in context.Skins
|
|
|
|
var skins = context.Champions.Where(c => c.Id == n.Id).SelectMany(c => c.Skins);
|
|
|
|
where n.Id == s.Id
|
|
|
|
|
|
|
|
select s;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
context.SaveChanges();
|
|
|
|
}
|
|
|
|
}
|
|
|
|