public async Task ExecuteAsync(string sql, CommandType commandType = CommandType.StoredProcedure) { await ExceptionConverter.CallAsync(async() => { using (var conn = new NpgsqlConnection(_connectionString)) { await conn.ExecuteAsync(sql, commandType: commandType); } }); }
public async Task ExecuteAsync(string sql, object parameters, CommandType commandType = CommandType.StoredProcedure) { await ExceptionConverter.CallAsync(async() => { using (var conn = new NpgsqlConnection(_connectionString)) { var res = await conn.ExecuteAsync(sql, parameters, commandType: commandType); return(res); } }); }
/// <summary> /// Get a list of items of type T from the database /// </summary> /// <param name="functionName"></param> /// <returns></returns> public async Task <IEnumerable <T> > GetListAsync(string sql, CommandType commandType = CommandType.StoredProcedure) { var res = await ExceptionConverter.CallAsync(async() => { using (var conn = new NpgsqlConnection(_connectionString)) { var res = await conn.QueryAsync <T>(sql, commandType: commandType); return(res); } }); return(res); }