What is the difference between using connection.OpenAsync() and connection.Open() when using dapper's QueryAsync method.
Async:
public async Task<IList<Product>> GetListAsync()
{
using (var connection = new SqlConnection(_connectionString))
{
StringBuilder sql = new StringBuilder();
sql.AppendLine("SELECT Id, Name ");
sql.AppendLine("FROM Product ");
await connection.OpenAsync();
var tickets = await connection.QueryAsync<Ticket>(sql.ToString());
return tickets.ToList();
}
}
Not Async:
public async Task<IList<Product>> GetListAsync()
{
using (var connection = new SqlConnection(_connectionString))
{
StringBuilder sql = new StringBuilder();
sql.AppendLine("SELECT Id, Name ");
sql.AppendLine("FROM Product ");
connection.Open();
var tickets = await connection.QueryAsync<Ticket>(sql.ToString());
return tickets.ToList();
}
}