Converted the project in C#, added Entity Framework Core.

This commit is contained in:
Samuele Lorefice
2023-11-06 20:38:28 +01:00
parent 0685bc33ce
commit f37998ca9f
27 changed files with 748 additions and 796 deletions

21
DbManager.cs Normal file
View File

@@ -0,0 +1,21 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
namespace IsleBot;
public class DbManager : DbContext {
public DbSet<User> Players { get; set; }
public DbSet<Card> Cards { get; set; }
public DbSet<Match> Matches { get; set; }
public string dbpath { get; } = "database.db";
public DbManager() {
var fullPath = Environment.CurrentDirectory + Path.DirectorySeparatorChar + dbpath;
dbpath = fullPath;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseSqlite($"Data Source={dbpath}");
}