From 24d4deab9a3335bb58cb82f780a9b37cffcabd9c Mon Sep 17 00:00:00 2001 From: expeehaa Date: Fri, 3 Jul 2020 22:50:52 +0200 Subject: [PATCH] Format file, remove outcommented code. --- src/MitternachtBot/Services/DbService.cs | 81 ++++++++++-------------- 1 file changed, 32 insertions(+), 49 deletions(-) diff --git a/src/MitternachtBot/Services/DbService.cs b/src/MitternachtBot/Services/DbService.cs index e8749efba..c58f3fc8c 100644 --- a/src/MitternachtBot/Services/DbService.cs +++ b/src/MitternachtBot/Services/DbService.cs @@ -1,53 +1,36 @@ using Microsoft.EntityFrameworkCore; using Mitternacht.Services.Database; -namespace Mitternacht.Services -{ - public class DbService - { - private readonly DbContextOptions _options; - - public DbService(IBotCredentials creds) - { - var optionsBuilder = new DbContextOptionsBuilder(); - optionsBuilder.UseSqlite(creds.DbConnectionString); - _options = optionsBuilder.Options; - //switch (_creds.Db.Type.ToUpperInvariant()) - //{ - // case "SQLITE": - // dbType = typeof(NadekoSqliteContext); - // break; - // //case "SQLSERVER": - // // dbType = typeof(NadekoSqlServerContext); - // // break; - // default: - // break; - - //} - } - - public NadekoContext GetDbContext() - { - var context = new NadekoContext(_options); - context.Database.SetCommandTimeout(60); - context.Database.Migrate(); - context.EnsureSeedData(); - - //set important sqlite stuffs - var conn = context.Database.GetDbConnection(); - conn.Open(); - - context.Database.ExecuteSqlRaw("PRAGMA journal_mode=WAL"); - using (var com = conn.CreateCommand()) - { - com.CommandText = "PRAGMA journal_mode=WAL; PRAGMA synchronous=OFF"; - com.ExecuteNonQuery(); - } - - return context; - } - - public IUnitOfWork UnitOfWork => - new UnitOfWork(GetDbContext()); - } +namespace Mitternacht.Services { + public class DbService { + private readonly DbContextOptions _options; + + public DbService(IBotCredentials creds) { + var optionsBuilder = new DbContextOptionsBuilder(); + optionsBuilder.UseSqlite(creds.DbConnectionString); + _options = optionsBuilder.Options; + } + + public NadekoContext GetDbContext() { + var context = new NadekoContext(_options); + context.Database.SetCommandTimeout(60); + context.Database.Migrate(); + context.EnsureSeedData(); + + //set important sqlite stuffs + var conn = context.Database.GetDbConnection(); + conn.Open(); + + context.Database.ExecuteSqlRaw("PRAGMA journal_mode=WAL"); + using(var com = conn.CreateCommand()) { + com.CommandText = "PRAGMA journal_mode=WAL; PRAGMA synchronous=OFF"; + com.ExecuteNonQuery(); + } + + return context; + } + + public IUnitOfWork UnitOfWork => + new UnitOfWork(GetDbContext()); + } } \ No newline at end of file