2020-06-11 20:29:16 +02:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using LinqToDB;
|
|
|
|
using LinqToDB.Configuration;
|
2020-06-12 00:37:55 +02:00
|
|
|
using LinqToDB.Data;
|
2022-04-29 14:59:24 +02:00
|
|
|
using trainav.web.database.Tables;
|
2020-06-11 20:29:16 +02:00
|
|
|
|
2022-05-03 00:20:02 +02:00
|
|
|
namespace trainav.web.database;
|
|
|
|
|
|
|
|
public class Database {
|
|
|
|
public class ConnectionStringSettings : IConnectionStringSettings {
|
|
|
|
public string ConnectionString { get; set; }
|
|
|
|
public string Name { get; set; }
|
|
|
|
public string ProviderName { get; set; }
|
|
|
|
public bool IsGlobal => false;
|
|
|
|
}
|
2020-06-11 20:29:16 +02:00
|
|
|
|
2022-05-03 00:20:02 +02:00
|
|
|
public class Settings : ILinqToDBSettings {
|
|
|
|
public IEnumerable<IDataProviderSettings> DataProviders => Enumerable.Empty<IDataProviderSettings>();
|
2020-06-11 20:29:16 +02:00
|
|
|
|
2022-05-03 00:20:02 +02:00
|
|
|
public string DefaultConfiguration => "SQLite";
|
|
|
|
public string DefaultDataProvider => "SQLite";
|
2020-06-11 20:29:16 +02:00
|
|
|
|
2022-05-03 00:20:02 +02:00
|
|
|
public IEnumerable<IConnectionStringSettings> ConnectionStrings {
|
|
|
|
get { yield return new ConnectionStringSettings { Name = "db", ProviderName = "SQLite", ConnectionString = @"Data Source=database.db;" }; }
|
2020-06-11 20:29:16 +02:00
|
|
|
}
|
2022-05-03 00:20:02 +02:00
|
|
|
}
|
2020-06-11 20:29:16 +02:00
|
|
|
|
2022-05-03 00:20:02 +02:00
|
|
|
public class DbConn : DataConnection {
|
|
|
|
public DbConn() : base("db") { }
|
2023-01-24 18:52:32 +01:00
|
|
|
public ITable<DbInfo> DbInfo => this.GetTable<DbInfo>();
|
2020-06-11 20:29:16 +02:00
|
|
|
|
2023-01-24 18:52:32 +01:00
|
|
|
public ITable<User> Users => this.GetTable<User>();
|
|
|
|
public ITable<Leg> Legs => this.GetTable<Leg>();
|
|
|
|
public ITable<Trip> Trips => this.GetTable<Trip>();
|
2020-06-11 20:29:16 +02:00
|
|
|
}
|
2022-05-03 00:59:32 +02:00
|
|
|
}
|