示例#1
0
 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);
         }
     });
 }
示例#2
0
 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);
         }
     });
 }
示例#3
0
        /// <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);
        }