public async Task <T> ExecuteScalarAsync <T>(string connection, string sql, object parameters) { T result = default; using (var c = new MySqlData.MySqlClient.MySqlConnection(connection)) { _log.LogTrace <MySqlQuery>($"EXECUTE: {sql}. Parameters: {JsonConvert.SerializeObject(parameters)}"); await c.OpenAsync(); result = await c.ExecuteScalarAsync <T>(sql, parameters); await c.CloseAsync(); } return(result); }