From 8e4db752ea112ee46f43470d9c635a437bd9d1b9 Mon Sep 17 00:00:00 2001 From: Theo DUPIN Date: Tue, 21 Mar 2023 12:36:40 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20Scores=20finaux=20dans=20la=20tabl?= =?UTF-8?q?e=20Score=20sachant=20l'Id=20de=20la=20Game=20et=20l'id=20du=20?= =?UTF-8?q?Player=20concern=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230321112754_AllMigrations.Designer.cs | 182 ++++++++++++++++++ .../20230321112754_AllMigrations.cs | 150 +++++++++++++++ .../Migrations/SQLiteContextModelSnapshot.cs | 179 +++++++++++++++++ Sources/Tests/DbConsole/Program.cs | 1 + .../Tests/DbConsole/projet.ToutesTables.db | Bin 0 -> 49152 bytes 5 files changed, 512 insertions(+) create mode 100644 Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.Designer.cs create mode 100644 Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.cs create mode 100644 Sources/Tests/DbConsole/Migrations/SQLiteContextModelSnapshot.cs create mode 100644 Sources/Tests/DbConsole/projet.ToutesTables.db diff --git a/Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.Designer.cs b/Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.Designer.cs new file mode 100644 index 0000000..a180f95 --- /dev/null +++ b/Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.Designer.cs @@ -0,0 +1,182 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace DbConsole.Migrations +{ + [DbContext(typeof(SQLiteContext))] + [Migration("20230321112754_AllMigrations")] + partial class AllMigrations + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFrameWorkLib.CaseEntity", b => + { + b.Property("CaseId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("CaseId"); + + b.ToTable("Case"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b => + { + b.Property("GameId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("NbPlayers") + .HasColumnType("INTEGER"); + + b.HasKey("GameId"); + + b.ToTable("Game"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GrilleEntity", b => + { + b.Property("GrilleId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxChain") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbChains") + .HasColumnType("INTEGER"); + + b.Property("NbZones") + .HasColumnType("INTEGER"); + + b.HasKey("GrilleId"); + + b.ToTable("Grille"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => + { + b.Property("PlayerId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxPoints") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbPlayed") + .HasColumnType("INTEGER"); + + b.Property("NbWin") + .HasColumnType("INTEGER"); + + b.Property("Pseudo") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("PlayerId"); + + b.ToTable("Players"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.Property("ScoreId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameId") + .HasColumnType("INTEGER"); + + b.Property("NbPointsTotal") + .HasColumnType("INTEGER"); + + b.Property("PlayerId") + .HasColumnType("INTEGER"); + + b.HasKey("ScoreId"); + + b.HasIndex("GameId"); + + b.HasIndex("PlayerId"); + + b.ToTable("Score"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.TurnEntity", b => + { + b.Property("TurnId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DiceValue1") + .HasColumnType("INTEGER"); + + b.Property("DiceValue2") + .HasColumnType("INTEGER"); + + b.HasKey("TurnId"); + + b.ToTable("Turn"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.HasOne("EntityFrameWorkLib.GameEntity", "Game") + .WithMany("Scores") + .HasForeignKey("GameId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameWorkLib.PlayerEntity", "Player") + .WithMany("Scores") + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Game"); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b => + { + b.Navigation("Scores"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => + { + b.Navigation("Scores"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.cs b/Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.cs new file mode 100644 index 0000000..f30d7c3 --- /dev/null +++ b/Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.cs @@ -0,0 +1,150 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DbConsole.Migrations +{ + /// + public partial class AllMigrations : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Case", + columns: table => new + { + CaseId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Value = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Case", x => x.CaseId); + }); + + migrationBuilder.CreateTable( + name: "Game", + columns: table => new + { + GameId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Duration = table.Column(type: "TEXT", nullable: false), + Date = table.Column(type: "TEXT", nullable: false), + NbPlayers = table.Column(type: "INTEGER", nullable: false), + Name = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Game", x => x.GameId); + }); + + migrationBuilder.CreateTable( + name: "Grille", + columns: table => new + { + GrilleId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + NbChains = table.Column(type: "INTEGER", nullable: false), + NbZones = table.Column(type: "INTEGER", nullable: false), + MaxChain = table.Column(type: "INTEGER", nullable: false), + MaxZone = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Grille", x => x.GrilleId); + }); + + migrationBuilder.CreateTable( + name: "Players", + columns: table => new + { + PlayerId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Pseudo = table.Column(type: "TEXT", nullable: false), + NbWin = table.Column(type: "INTEGER", nullable: false), + NbPlayed = table.Column(type: "INTEGER", nullable: false), + MaxZone = table.Column(type: "INTEGER", nullable: false), + MaxPoints = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Players", x => x.PlayerId); + }); + + migrationBuilder.CreateTable( + name: "Turn", + columns: table => new + { + TurnId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + DiceValue1 = table.Column(type: "INTEGER", nullable: false), + DiceValue2 = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Turn", x => x.TurnId); + }); + + migrationBuilder.CreateTable( + name: "Score", + columns: table => new + { + ScoreId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + NbPointsTotal = table.Column(type: "INTEGER", nullable: false), + GameId = table.Column(type: "INTEGER", nullable: false), + PlayerId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Score", x => x.ScoreId); + table.ForeignKey( + name: "FK_Score_Game_GameId", + column: x => x.GameId, + principalTable: "Game", + principalColumn: "GameId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Score_Players_PlayerId", + column: x => x.PlayerId, + principalTable: "Players", + principalColumn: "PlayerId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Score_GameId", + table: "Score", + column: "GameId"); + + migrationBuilder.CreateIndex( + name: "IX_Score_PlayerId", + table: "Score", + column: "PlayerId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Case"); + + migrationBuilder.DropTable( + name: "Grille"); + + migrationBuilder.DropTable( + name: "Score"); + + migrationBuilder.DropTable( + name: "Turn"); + + migrationBuilder.DropTable( + name: "Game"); + + migrationBuilder.DropTable( + name: "Players"); + } + } +} diff --git a/Sources/Tests/DbConsole/Migrations/SQLiteContextModelSnapshot.cs b/Sources/Tests/DbConsole/Migrations/SQLiteContextModelSnapshot.cs new file mode 100644 index 0000000..5b4d8bc --- /dev/null +++ b/Sources/Tests/DbConsole/Migrations/SQLiteContextModelSnapshot.cs @@ -0,0 +1,179 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace DbConsole.Migrations +{ + [DbContext(typeof(SQLiteContext))] + partial class SQLiteContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFrameWorkLib.CaseEntity", b => + { + b.Property("CaseId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("CaseId"); + + b.ToTable("Case"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b => + { + b.Property("GameId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("NbPlayers") + .HasColumnType("INTEGER"); + + b.HasKey("GameId"); + + b.ToTable("Game"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GrilleEntity", b => + { + b.Property("GrilleId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxChain") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbChains") + .HasColumnType("INTEGER"); + + b.Property("NbZones") + .HasColumnType("INTEGER"); + + b.HasKey("GrilleId"); + + b.ToTable("Grille"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => + { + b.Property("PlayerId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxPoints") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbPlayed") + .HasColumnType("INTEGER"); + + b.Property("NbWin") + .HasColumnType("INTEGER"); + + b.Property("Pseudo") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("PlayerId"); + + b.ToTable("Players"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.Property("ScoreId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameId") + .HasColumnType("INTEGER"); + + b.Property("NbPointsTotal") + .HasColumnType("INTEGER"); + + b.Property("PlayerId") + .HasColumnType("INTEGER"); + + b.HasKey("ScoreId"); + + b.HasIndex("GameId"); + + b.HasIndex("PlayerId"); + + b.ToTable("Score"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.TurnEntity", b => + { + b.Property("TurnId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DiceValue1") + .HasColumnType("INTEGER"); + + b.Property("DiceValue2") + .HasColumnType("INTEGER"); + + b.HasKey("TurnId"); + + b.ToTable("Turn"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.HasOne("EntityFrameWorkLib.GameEntity", "Game") + .WithMany("Scores") + .HasForeignKey("GameId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameWorkLib.PlayerEntity", "Player") + .WithMany("Scores") + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Game"); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b => + { + b.Navigation("Scores"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => + { + b.Navigation("Scores"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/Tests/DbConsole/Program.cs b/Sources/Tests/DbConsole/Program.cs index 0b4c5db..04a07cb 100644 --- a/Sources/Tests/DbConsole/Program.cs +++ b/Sources/Tests/DbConsole/Program.cs @@ -25,6 +25,7 @@ using Model; context.SaveChanges(); }*/ +// Ajout de 3 Game, 1 Player "Jax" et 3 Scores totaux dans chaque Game attribués au Player par son Id using (var context = new SQLiteContext()) { var firstGame = new GameEntity diff --git a/Sources/Tests/DbConsole/projet.ToutesTables.db b/Sources/Tests/DbConsole/projet.ToutesTables.db new file mode 100644 index 0000000000000000000000000000000000000000..64c543247440e85850ba0fbc5733411fe083c889 GIT binary patch literal 49152 zcmeI*%}?8A90zbeHslrRNfokMG|hE)0MXJUtU}spSz=gLaMHwWq0$r?;;oj_MA(i* z4?7el?GNbRvBOR~?_bz)nzl)trm1QVdy}@qp69V0a9$usg1(lM*iWA4=jZo%9w(TW z(0I7z__q3a*L`mJ>YDJ5Ad13AswxPAL~nES7AU~HgC?${|MQn zEnNFS{^r{K`IEWV*rhiW<$?s_~76?E90uX?})f9M|O(^#i@}<*h*@u;#W@EqW z+Ra+qdSSbj7T=pI)%BvOs}-ZH@2J{PB~7gws>Z8o>XH_<)t1dnLRnErFCKf-dTxi2 zvtuF$RR-dQh0Dhe(@8~9$k)WT_S!Z-F2Bo!(ahqxOwJ3~21tx=zRU z%&u>>hr>qIqFe?K8$I9W8tPbB<81df!tOO$RDQ=Y+Njp`%BI1)x}-%;YF*#Z>$*|W z8!9hkgVTSK4p~{>(&@04ij7jStegMWmX41oE26sEc$IVMR zz1fSvh!Z9Xux%Ya?RM<(A!vo*6dA6)H%`hgc!IJZJBqO|SQw zo_)}>JNx#)?rcnA;K`*94S$EWTz+{|3SLPR982 z49@~K$U7vdtgn-!D(_sgsc&pMUj*vjCywWL-4`PZ#d!Be);Z0mACn~&BOiRP8x!bE ziqZ71x!qQ8-+yeo-tZKmsa3>;^4U5O_u0_^%LoqQek?00bZa0SG_< z0uX=z1Rwx`X%*0-+-tTsTN*Wm# zXv1+mp9jM4|4-{QLBAmY0SG_<0uX=z1Rwwb2tWV=lMArxenXZ?Y8~R||5s>WkqQJL009U<00Izz00bZa0SG`~j6m@B z|0ja{xBOZ@8B+MD-c3tNlb}+D