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.

69 lines
1.5 KiB

// See https://aka.ms/new-console-template for more information
using DBEntitiesWithStub;
using EntityFrameworkLib;
using Microsoft.EntityFrameworkCore;
ChampionEntity jax = new ChampionEntity
{
Name = "Jax",
Icon = "icon Jax",
Bio = "bio Jax"
};
ChampionEntity darius = new ChampionEntity
{
Name = "Darius",
Icon = "icon Darius",
Bio = "bio Darius"
};
ChampionEntity garen = new ChampionEntity
{
Name = "Garen",
Icon = "icon Garen",
Bio = "bio Garen"
};
ChampionEntity veigar = new ChampionEntity
{
Name = "Veigar",
Icon = "icon Veigar",
Bio = "bio Veigar"
};
using (var context = new SQLiteLolContext())
{
Console.WriteLine("Creates and inserts new Champion");
/*context.Add(garen);
context.Add(darius);
context.Add(jax);
context.Add(veigar);*/
context.SaveChanges();
}
using (var context = new SQLiteLolContext())
{
foreach(var n in context.Champions)
{
Console.WriteLine($"{n.Id} {n.Name}");
}
context.SaveChanges();
}
using (LolContext db = new ChampionsDBEntitiesWithStub())
{
Console.WriteLine("Contenu de la base :");
foreach(var n in db.Champions)
{
Console.WriteLine($"\t{n.Id} - {n.Name} - {n.Bio} - {n.Icon}");
}
}
public class SQLiteLolContext : LolContext
{
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
if (!options.IsConfigured)
{
options.UseSqlite($"Data Source=projet.Champions.db");
}
}
}