#if ASYNC
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Dapper
{
public static partial class SqlMapper
{
///
/// Execute a query asynchronously using .NET 4.5 Task.
///
/// Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object>
public static Task> QueryAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return QueryAsync(cnn, typeof(DapperRow), new CommandDefinition(sql, param, transaction, commandTimeout, commandType, CommandFlags.Buffered, default(CancellationToken)));
}
///
/// Execute a query asynchronously using .NET 4.5 Task.
///
/// Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object>
public static Task> QueryAsync(this IDbConnection cnn, CommandDefinition command)
{
return QueryAsync(cnn, typeof(DapperRow), command);
}
///
/// Execute a single-row query asynchronously using .NET 4.5 Task.
///
/// Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object>
public static Task QueryFirstAsync(this IDbConnection cnn, CommandDefinition command)
{
return QueryRowAsync(cnn, Row.First, typeof(DapperRow), command);
}
///
/// Execute a single-row query asynchronously using .NET 4.5 Task.
///
/// Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object>
public static Task QueryFirstOrDefaultAsync(this IDbConnection cnn, CommandDefinition command)
{
return QueryRowAsync(cnn, Row.FirstOrDefault, typeof(DapperRow), command);
}
///
/// Execute a single-row query asynchronously using .NET 4.5 Task.
///
/// Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object>
public static Task QuerySingleAsync(this IDbConnection cnn, CommandDefinition command)
{
return QueryRowAsync(cnn, Row.Single, typeof(DapperRow), command);
}
///
/// Execute a single-row query asynchronously using .NET 4.5 Task.
///
/// Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object>
public static Task QuerySingleOrDefaultAsync(this IDbConnection cnn, CommandDefinition command)
{
return QueryRowAsync(cnn, Row.SingleOrDefault, typeof(DapperRow), command);
}
///
/// Execute a query asynchronously using .NET 4.5 Task.
///
public static Task> QueryAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return QueryAsync(cnn, typeof(T), new CommandDefinition(sql, param, transaction, commandTimeout, commandType, CommandFlags.Buffered, default(CancellationToken)));
}
///
/// Execute a single-row query asynchronously using .NET 4.5 Task.
///
public static Task QueryFirstAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return QueryRowAsync(cnn, Row.First, typeof(T), new CommandDefinition(sql, param, transaction, commandTimeout, commandType, CommandFlags.None, default(CancellationToken)));
}
///
/// Execute a single-row query asynchronously using .NET 4.5 Task.
///
public static Task QueryFirstOrDefaultAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return QueryRowAsync(cnn, Row.FirstOrDefault, typeof(T), new CommandDefinition(sql, param, transaction, commandTimeout, commandType, CommandFlags.None, default(CancellationToken)));
}
///
/// Execute a single-row query asynchronously using .NET 4.5 Task.
///
public static Task QuerySingleAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return QueryRowAsync(cnn, Row.Single, typeof(T), new CommandDefinition(sql, param, transaction, commandTimeout, commandType, CommandFlags.None, default(CancellationToken)));
}
///
/// Execute a single-row query asynchronously using .NET 4.5 Task.
///
public static Task QuerySingleOrDefaultAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return QueryRowAsync(cnn, Row.SingleOrDefault, typeof(T), new CommandDefinition(sql, param, transaction, commandTimeout, commandType, CommandFlags.None, default(CancellationToken)));
}
///
/// Execute a query asynchronously using .NET 4.5 Task.
///
public static Task> QueryAsync(this IDbConnection cnn, Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
if (type == null) throw new ArgumentNullException(nameof(type));
return QueryAsync