---
title: "Handling async/await with Dapper in ASP.NET Core controllers"  
description: "Handling async/await with Dapper in ASP.NET Core controllers"  
author: "Rana Sunny"  
published: 2026-09-30  
updated: 2026-09-30  
canonical: https://www.mindstick.com/forum/162222/handling-async-await-with-dapper-in-asp-net-core-controllers  
category: "Concurrency"  
tags: ["Dapper", "Async", "asp.net core", "Controllers", "Concurrency"]  
reading_time: 1 minute  

---

# Handling async/await with Dapper in ASP.NET Core controllers

I keep seeing `QueryAsync` and `ExecuteAsync` everywhere, but I'm not 100% sure when to actually await them inside a controller action. If I fire off multiple Dapper calls in parallel using `Task.WhenAll`, do I need to worry about thread-safety or connection leaks?

Specifically, I have a controller that fetches a user profile and their recent orders in one request. My first attempt looks like this:

```cs
public async Task<IActionResult> GetProfile(int userId)
{
    // Open connection manually — is this okay?
    using var conn = new SqlConnection(_connectionString);
    await conn.OpenAsync();

    var profileTask = conn.QueryFirstOrDefaultAsync<User>(
        "SELECT * FROM Users WHERE Id = @Id",
        new { Id = userId });

    var ordersTask = conn.QueryAsync<Order>(
        "SELECT * FROM Orders WHERE UserId = @Id",
        new { Id = userId });

    await Task.WhenAll(profileTask, ordersTask);

    return Ok(new { Profile = profileTask.Result, Orders = ordersTask.Result });
}
```

I know mixing `.Result` with `await` is usually a bad idea, but I'm not sure how to restructure this cleanly. Should I be opening the connection per-query, or is a single `Scoped` connection better? Any advice on avoiding deadlocks or connection exhaustion under concurrent load would be appreciated.


---

Original Source: https://www.mindstick.com/forum/162222/handling-async-await-with-dapper-in-asp-net-core-controllers

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
