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-04-29 14:59:24 +02:00
|
|
|
namespace trainav.web.database {
|
2020-06-11 20:29:16 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
public class Settings : ILinqToDBSettings {
|
|
|
|
public IEnumerable<IDataProviderSettings> DataProviders => Enumerable.Empty<IDataProviderSettings>();
|
|
|
|
|
|
|
|
public string DefaultConfiguration => "SQLite";
|
|
|
|
public string DefaultDataProvider => "SQLite";
|
|
|
|
|
|
|
|
public IEnumerable<IConnectionStringSettings> ConnectionStrings {
|
2022-03-20 02:30:56 +01:00
|
|
|
get { yield return new ConnectionStringSettings { Name = "db", ProviderName = "SQLite", ConnectionString = @"Data Source=database.db;" }; }
|
2020-06-11 20:29:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-12 00:37:55 +02:00
|
|
|
public class DbConn : DataConnection {
|
2020-06-11 20:29:16 +02:00
|
|
|
public DbConn() : base("db") { }
|
2022-03-20 02:30:56 +01:00
|
|
|
public ITable<DbInfo> DbInfo => GetTable<DbInfo>();
|
2020-06-11 20:29:16 +02:00
|
|
|
|
2020-06-12 00:37:55 +02:00
|
|
|
public ITable<User> Users => GetTable<User>();
|
|
|
|
public ITable<Leg> Legs => GetTable<Leg>();
|
|
|
|
public ITable<Ticket> Tickets => GetTable<Ticket>();
|
2020-06-11 20:29:16 +02:00
|
|
|
public ITable<TicketLeg> TicketLegs => GetTable<TicketLeg>();
|
2020-06-12 00:37:55 +02:00
|
|
|
public ITable<Trip> Trips => GetTable<Trip>();
|
|
|
|
public ITable<Card> Cards => GetTable<Card>();
|
2020-06-11 20:29:16 +02:00
|
|
|
}
|
|
|
|
}
|
2022-03-20 02:30:56 +01:00
|
|
|
}
|