From 56df72f1f23da185315fe073fe3dbcd0c722e1b4 Mon Sep 17 00:00:00 2001 From: pasquizzat Date: Thu, 26 Jan 2023 09:58:30 +0100 Subject: [PATCH] =?UTF-8?q?Ok=20Paul,=20il=20faudrait=20que=20tu=20regarde?= =?UTF-8?q?s=20le=20program.cs=20de=20Test=20LaConsolePourLaBd,=20puis=20q?= =?UTF-8?q?ue=20tu=20r=C3=A9ussises=20=C3=A0=20faire=20les=20trucs=20conso?= =?UTF-8?q?le,=20s'il=20te=20plait.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/LeagueOfLegends.sln | 31 ++++++++---- Sources/Model/Model.csproj | 9 ++++ Sources/Model2/ChampionContexte.cs | 16 ++++++ Sources/Model2/ChampionEntity.cs | 16 ++++++ ...0230126085130_myFirstMigration.Designer.cs | 47 ++++++++++++++++++ .../20230126085130_myFirstMigration.cs | 36 ++++++++++++++ .../ChampionContexteModelSnapshot.cs | 44 ++++++++++++++++ Sources/Model2/Model2.csproj | 25 ++++++++++ Sources/Model2/laBdd.db | Bin 0 -> 20480 bytes .../LaConsolePourLaBdd.csproj | 21 ++++++++ Sources/Tests/LaConsolePourLaBdd/Program.cs | 21 ++++++++ 11 files changed, 257 insertions(+), 9 deletions(-) create mode 100644 Sources/Model2/ChampionContexte.cs create mode 100644 Sources/Model2/ChampionEntity.cs create mode 100644 Sources/Model2/Migrations/20230126085130_myFirstMigration.Designer.cs create mode 100644 Sources/Model2/Migrations/20230126085130_myFirstMigration.cs create mode 100644 Sources/Model2/Migrations/ChampionContexteModelSnapshot.cs create mode 100644 Sources/Model2/Model2.csproj create mode 100644 Sources/Model2/laBdd.db create mode 100644 Sources/Tests/LaConsolePourLaBdd/LaConsolePourLaBdd.csproj create mode 100644 Sources/Tests/LaConsolePourLaBdd/Program.cs diff --git a/Sources/LeagueOfLegends.sln b/Sources/LeagueOfLegends.sln index 0ea57ff..4f57c62 100644 --- a/Sources/LeagueOfLegends.sln +++ b/Sources/LeagueOfLegends.sln @@ -1,19 +1,23 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 25.0.1704.2 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32616.157 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{2960F9BA-49DE-494D-92E3-CE5A794BA1A9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj", "{2960F9BA-49DE-494D-92E3-CE5A794BA1A9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{C76D0C23-1FFA-4963-93CD-E12BD643F030}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTests", "Tests\ConsoleTests\ConsoleTests.csproj", "{1889FA6E-B7C6-416E-8628-9449FB9070B9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTests", "Tests\ConsoleTests\ConsoleTests.csproj", "{1889FA6E-B7C6-416E-8628-9449FB9070B9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{3B720C0C-53FE-4642-A2DB-87FD8634CD74}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shared", "Shared\Shared.csproj", "{3B720C0C-53FE-4642-A2DB-87FD8634CD74}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Stub", "Stub", "{2C607793-B163-4731-A4D1-AFE8A7C4C170}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubLib", "StubLib\StubLib.csproj", "{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubLib", "StubLib\StubLib.csproj", "{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model2", "Model2\Model2.csproj", "{D7FE55BA-1CEE-4C9D-B2FA-674D61F1B7A5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaConsolePourLaBdd", "Tests\LaConsolePourLaBdd\LaConsolePourLaBdd.csproj", "{088B9AD5-9EF4-4B56-8883-202489984E27}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -37,15 +41,24 @@ Global {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Debug|Any CPU.Build.0 = Debug|Any CPU {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Release|Any CPU.ActiveCfg = Release|Any CPU {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Release|Any CPU.Build.0 = Release|Any CPU + {D7FE55BA-1CEE-4C9D-B2FA-674D61F1B7A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7FE55BA-1CEE-4C9D-B2FA-674D61F1B7A5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7FE55BA-1CEE-4C9D-B2FA-674D61F1B7A5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7FE55BA-1CEE-4C9D-B2FA-674D61F1B7A5}.Release|Any CPU.Build.0 = Release|Any CPU + {088B9AD5-9EF4-4B56-8883-202489984E27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {088B9AD5-9EF4-4B56-8883-202489984E27}.Debug|Any CPU.Build.0 = Debug|Any CPU + {088B9AD5-9EF4-4B56-8883-202489984E27}.Release|Any CPU.ActiveCfg = Release|Any CPU + {088B9AD5-9EF4-4B56-8883-202489984E27}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9} - EndGlobalSection GlobalSection(NestedProjects) = preSolution {1889FA6E-B7C6-416E-8628-9449FB9070B9} = {C76D0C23-1FFA-4963-93CD-E12BD643F030} {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170} + {088B9AD5-9EF4-4B56-8883-202489984E27} = {C76D0C23-1FFA-4963-93CD-E12BD643F030} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9} EndGlobalSection EndGlobal diff --git a/Sources/Model/Model.csproj b/Sources/Model/Model.csproj index 27b2839..dab504c 100644 --- a/Sources/Model/Model.csproj +++ b/Sources/Model/Model.csproj @@ -12,6 +12,15 @@ + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/Sources/Model2/ChampionContexte.cs b/Sources/Model2/ChampionContexte.cs new file mode 100644 index 0000000..06d752b --- /dev/null +++ b/Sources/Model2/ChampionContexte.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +namespace Model2 +{ + internal class ChampionContexte : DbContext + { + public DbSet champs { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder options) + => options.UseSqlite("DataSource=laBdd.db"); + } +} diff --git a/Sources/Model2/ChampionEntity.cs b/Sources/Model2/ChampionEntity.cs new file mode 100644 index 0000000..8204768 --- /dev/null +++ b/Sources/Model2/ChampionEntity.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model2 +{ + internal class ChampionEntity + { + public int Id { get; set; } + public string Name { get; set; } + public string Bio { get; set; } + public string Icon { get; set; } + } +} diff --git a/Sources/Model2/Migrations/20230126085130_myFirstMigration.Designer.cs b/Sources/Model2/Migrations/20230126085130_myFirstMigration.Designer.cs new file mode 100644 index 0000000..d5abbad --- /dev/null +++ b/Sources/Model2/Migrations/20230126085130_myFirstMigration.Designer.cs @@ -0,0 +1,47 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Model2; + +#nullable disable + +namespace Model2.Migrations +{ + [DbContext(typeof(ChampionContexte))] + [Migration("20230126085130_myFirstMigration")] + partial class myFirstMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("Model2.ChampionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Bio") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("champs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/Model2/Migrations/20230126085130_myFirstMigration.cs b/Sources/Model2/Migrations/20230126085130_myFirstMigration.cs new file mode 100644 index 0000000..bf8d6fb --- /dev/null +++ b/Sources/Model2/Migrations/20230126085130_myFirstMigration.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Model2.Migrations +{ + /// + public partial class myFirstMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "champs", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: false), + Bio = table.Column(type: "TEXT", nullable: false), + Icon = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_champs", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "champs"); + } + } +} diff --git a/Sources/Model2/Migrations/ChampionContexteModelSnapshot.cs b/Sources/Model2/Migrations/ChampionContexteModelSnapshot.cs new file mode 100644 index 0000000..b020600 --- /dev/null +++ b/Sources/Model2/Migrations/ChampionContexteModelSnapshot.cs @@ -0,0 +1,44 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Model2; + +#nullable disable + +namespace Model2.Migrations +{ + [DbContext(typeof(ChampionContexte))] + partial class ChampionContexteModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("Model2.ChampionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Bio") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("champs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/Model2/Model2.csproj b/Sources/Model2/Model2.csproj new file mode 100644 index 0000000..f8474a9 --- /dev/null +++ b/Sources/Model2/Model2.csproj @@ -0,0 +1,25 @@ + + + + net6.0 + enable + enable + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/Sources/Model2/laBdd.db b/Sources/Model2/laBdd.db new file mode 100644 index 0000000000000000000000000000000000000000..04919bc0ad88c1b9c49c10aa0288d130ed1a8baa GIT binary patch literal 20480 zcmeI&&rh3R7zgn8rB!DW>~2I)Z@5gOX=t0RI}Qy_(iS?z#U2*ITDFl`P@u_r)c+*5WK_<5}~4!%N>E@brB?aDn#pQzy&<@hwh9ekPjiHIpRvK?uf}M0Jg7 zUZ(wW-l0$asJ*Hwv6{CdSMOL^{>`@jRDW$TYM?*>0uX=z1Rwwb2tWV=5P-lF0=@FO zvcJ#!ng8`7NUtvF(alSPt8owwiruv%$Ix9vxcXto5QSrRBYzYe(3yMJc47j)cZkI?8+5EMKy=2FfG^kXgI>MU16PdI^xK-PF+W*aiR9wUVcu` zF}u3c7j2_2^fT8sEsEVWEcaj@%%b(E!Zpq*&OBB=br{AgX3Rkx6{h6M-t{@(P+Bd1 zW6v`3Jma_IdwJzjn3aEWfTSJRtKrpl|gj5ZVqKmY;| zfB*y_009U<00Izz00f?wz#Cp_D-EsD)as3Q+WWWlrsj<%$6=CY4=*lSHLcdDP+q+H zm(hj-0SG_<0uX=z1Rwwb2tWV=5P-mQ6i`d;%_m+0On?8UKmDUX00Izz00bZa0SG_< p0uX=z1R(H&1@Qd;f-f#og8&2|009U<00Izz00bZa0SL?m{sFSH*na>3 literal 0 HcmV?d00001 diff --git a/Sources/Tests/LaConsolePourLaBdd/LaConsolePourLaBdd.csproj b/Sources/Tests/LaConsolePourLaBdd/LaConsolePourLaBdd.csproj new file mode 100644 index 0000000..725fe1d --- /dev/null +++ b/Sources/Tests/LaConsolePourLaBdd/LaConsolePourLaBdd.csproj @@ -0,0 +1,21 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + + + + + + + diff --git a/Sources/Tests/LaConsolePourLaBdd/Program.cs b/Sources/Tests/LaConsolePourLaBdd/Program.cs new file mode 100644 index 0000000..e94ed74 --- /dev/null +++ b/Sources/Tests/LaConsolePourLaBdd/Program.cs @@ -0,0 +1,21 @@ +using Model2; + +static void Main(string[] args) +{ + Nounours chewie = new Nounours { Nom = "Chewbacca", Naissance = new DateTime(1977, 5, 27), NbPoils = 1234567 }; + ChampionEntity c1 = new ChampionEntity(); + + //JAI PAS ENCORE FAIT + + + using (var context = new NounoursContext()) + { + // Crée des nounours et les insère dans la base + Console.WriteLine("Creates and inserts new Nounours"); + context.Add(chewie); + context.Add(yoda); + context.Add(ewok); + context.Add(c3po); + context.SaveChanges(); + } +} \ No newline at end of file