diff --git a/Repositories/Resgrid.Repositories.DataRepository/ClaimsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ClaimsRepository.cs index d9ebf40e..4dab9e23 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ClaimsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ClaimsRepository.cs @@ -19,7 +19,7 @@ public async Task> GetRolesAsync(IdentityUser user) { if (Config.DataConfig.DatabaseType == DatabaseTypes.Postgres) { - var query = $@"SELECT anr.name FROM aspnetuserroles anur + var query = @"SELECT anr.name FROM aspnetuserroles anur INNER JOIN aspnetroles anr ON anur.roleid = anr.id WHERE anur.userid = @userId"; @@ -31,7 +31,7 @@ public async Task> GetRolesAsync(IdentityUser user) } else { - var query = $@"SELECT anr.Name FROM AspNetUserRoles anur + var query = @"SELECT anr.Name FROM AspNetUserRoles anur INNER JOIN AspNetRoles anr ON anur.RoleId = anr.Id WHERE anur.UserId = @userId"; @@ -49,7 +49,7 @@ public async Task FindByIdAsync(string userId) { if (Config.DataConfig.DatabaseType == DatabaseTypes.Postgres) { - var query = $@"SELECT * FROM aspnetusers WHERE id = @userId"; + var query = @"SELECT * FROM aspnetusers WHERE id = @userId"; using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) { @@ -58,7 +58,7 @@ public async Task FindByIdAsync(string userId) } else { - var query = $@"SELECT * FROM AspNetUsers WHERE Id = @userId"; + var query = @"SELECT * FROM AspNetUsers WHERE Id = @userId"; using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { diff --git a/Repositories/Resgrid.Repositories.DataRepository/ScheduledTaskLogsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ScheduledTaskLogsRepository.cs index 4ed6ae89..c58d4df1 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ScheduledTaskLogsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ScheduledTaskLogsRepository.cs @@ -59,14 +59,14 @@ public async Task> GetAllLogForDateAsync(DateTime { using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) { - return (await db.QueryAsync($"SELECT * FROM scheduledtasklogs WHERE CAST(rundate AS DATE) = CAST(@timeStamp AS DATE)", new { timeStamp = timeStamp })).ToList(); + return (await db.QueryAsync("SELECT * FROM scheduledtasklogs WHERE CAST(rundate AS DATE) = CAST(@timeStamp AS DATE)", new { timeStamp = timeStamp })).ToList(); } } else { using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { - return await db.QueryAsync($"SELECT * FROM ScheduledTaskLogs WHERE CAST(RunDate AS DATE) = CAST(@timeStamp AS DATE)", new { timeStamp = timeStamp }); + return await db.QueryAsync("SELECT * FROM ScheduledTaskLogs WHERE CAST(RunDate AS DATE) = CAST(@timeStamp AS DATE)", new { timeStamp = timeStamp }); } } } @@ -77,7 +77,7 @@ public async Task GetLogForTaskAndDateAsync(int scheduledTaskI { using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) { - var items = await db.QueryAsync($"SELECT * FROM scheduledtasklogs WHERE scheduledtaskid = @scheduledTaskId AND CAST(rundate AS DATE) = CAST(@timeStamp AS DATE)", new { scheduledTaskId = scheduledTaskId, timeStamp = timeStamp }); + var items = await db.QueryAsync("SELECT * FROM scheduledtasklogs WHERE scheduledtaskid = @scheduledTaskId AND CAST(rundate AS DATE) = CAST(@timeStamp AS DATE)", new { scheduledTaskId = scheduledTaskId, timeStamp = timeStamp }); return items.FirstOrDefault(); } } @@ -85,7 +85,7 @@ public async Task GetLogForTaskAndDateAsync(int scheduledTaskI { using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { - var items = await db.QueryAsync($"SELECT * FROM ScheduledTaskLogs WHERE ScheduledTaskId = @scheduledTaskId AND CAST(RunDate AS DATE) = CAST(@timeStamp AS DATE)", new { scheduledTaskId = scheduledTaskId, timeStamp = timeStamp }); + var items = await db.QueryAsync("SELECT * FROM ScheduledTaskLogs WHERE ScheduledTaskId = @scheduledTaskId AND CAST(RunDate AS DATE) = CAST(@timeStamp AS DATE)", new { scheduledTaskId = scheduledTaskId, timeStamp = timeStamp }); return items.FirstOrDefault(); } } diff --git a/Tools/Resgrid.Console/Commands/DbUpdateCommand.cs b/Tools/Resgrid.Console/Commands/DbUpdateCommand.cs index f5a10477..8e099d51 100644 --- a/Tools/Resgrid.Console/Commands/DbUpdateCommand.cs +++ b/Tools/Resgrid.Console/Commands/DbUpdateCommand.cs @@ -80,7 +80,7 @@ private static IServiceProvider CreateServices() // Add SQL Server support to FluentMigrator .AddSqlServer() // Set the connection string - .WithGlobalConnectionString(System.Configuration.ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString) + .WithGlobalConnectionString(Config.DataConfig.CoreConnectionString) // Define the assembly containing the migrations .ScanIn(typeof(M0001_InitialMigration).Assembly).For.Migrations().For.EmbeddedResources()) // Enable logging to console in the FluentMigrator way diff --git a/Workers/Resgrid.Workers.Console/Program.cs b/Workers/Resgrid.Workers.Console/Program.cs index 9a683cc5..2056078b 100644 --- a/Workers/Resgrid.Workers.Console/Program.cs +++ b/Workers/Resgrid.Workers.Console/Program.cs @@ -464,7 +464,7 @@ private static IServiceProvider CreateServices() // Add SQL Server support to FluentMigrator .AddSqlServer() // Set the connection string - .WithGlobalConnectionString(System.Configuration.ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString) + .WithGlobalConnectionString(Config.DataConfig.CoreConnectionString) // Define the assembly containing the migrations .ScanIn(typeof(M0001_InitialMigration).Assembly).For.Migrations().For.EmbeddedResources()) // Enable logging to console in the FluentMigrator way