Search code examples
dappernpgsql

Does Npgsql support async?


From this question it seems that Npgsql doesn't support async so I start to replace all my calls by synchronous ones, but the answer is very old and I would like to know if it still applies AsyncQuery with postgresql and dapper using npqsql

This is how most of my code looks like

using Dapper;

using(var connection = new NpgsqlConnection(connectionString))
{
    var myResult = connection.QueryAsync<MyModel>(
         "SELECT * FROM my_model_table WHERE id = @id"), new { id });
}

Solution

  • Yes, recent versions of Npgsql are fully asynchronous. Calling async ADO.NET APIs will properly perform async network operations.