You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
4.9 KiB
107 lines
4.9 KiB
using EntityFrameworkLOL.DBContexts;
|
|
using EntityFrameworkLOL.Entities;
|
|
using System.Linq;
|
|
using System;
|
|
using System.Text;
|
|
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
/*ChampionEntity akali = new ChampionEntity { Id = 1, Name = "Akali", Bio = "" };
|
|
ChampionEntity aatrox = new ChampionEntity { Id = 2, Name = "Aatrox", Bio = "" };
|
|
ChampionEntity ahri = new ChampionEntity { Id = 3, Name = "Ahri", Bio = "" };
|
|
ChampionEntity bard = new ChampionEntity { Id = 4, Name = "Bard", Bio = "" };
|
|
ChampionEntity alistar = new ChampionEntity { Id = 5, Name = "Alistar", Bio = "" };
|
|
ChampionEntity akshan = new ChampionEntity { Id = 6, Name = "Akshan", Bio = "" };
|
|
|
|
using (var context = new ChampionContext())
|
|
{
|
|
// Crée des champions et les insère dans la base
|
|
Console.WriteLine("Creates and inserts new Champions");
|
|
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 { Id = 1, Name = "Conqueror", Description = "" };
|
|
RuneEntity thriumph = new RuneEntity { Id = 2, Name = "Thriumph", Description = "" };
|
|
RuneEntity alacrity = new RuneEntity { Id = 3, Name = "Legend : Alacrity", Description = "" };
|
|
RuneEntity tenacity = new RuneEntity { Id = 4, Name = "Legend : Tenacity", Description = "" };
|
|
RuneEntity laststand = new RuneEntity { Id = 5, Name = "Last Stand", Description = "" };
|
|
RuneEntity laststand2 = new RuneEntity { Id = 6, Name = "Last Stand 2", Description = "" };
|
|
|
|
using (var context = new RuneContext())
|
|
{
|
|
// Crée des Runes et les insère dans la base
|
|
Console.WriteLine("Creates and inserts new Runes");
|
|
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 { Id = 1, Name = "Stinger", Description = "" };
|
|
SkinEntity infernal = new SkinEntity { Id = 2, Name = "Infernal", Description = "" };
|
|
SkinEntity allStar = new SkinEntity { Id = 3, Name = "All-Star", Description = "" };
|
|
SkinEntity justicar = new SkinEntity { Id = 4, Name = "Justicar", Description = "" };
|
|
SkinEntity mecha = new SkinEntity { Id = 5, Name = "Mecha", Description = "" };
|
|
SkinEntity seaHunter = new SkinEntity { Id = 6, Name = "Sea Hunter", Description = "" };
|
|
|
|
using (var context = new SkinContext())
|
|
{
|
|
// Crée des Skins et les insère dans la base
|
|
Console.WriteLine("Creates and inserts new Skins");
|
|
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 ChampionContext())
|
|
{
|
|
foreach (var c in context.Champion)
|
|
{
|
|
c.Bio = $"{c.Name}";
|
|
Console.WriteLine($"{c.Name} - {c.Bio}");
|
|
}
|
|
context.SaveChanges();
|
|
}
|
|
}
|
|
} |