ADO.Net Async with Transactions... A Lesson Learned
Last night I was testing out a new WebApi Filter I've added to a project, its fairly simple, log some data that comes from a HTTP header to the DB. This particular project has no Entity Framework or anything, just simple ADO.Net, in fact I think the project has 3 stored proc's in total. I tend to Async all the things by default so when I originally wrote my DB code I had: using (var conn = new SqlConnection(_connectionString)) { await conn.OpenAsync(); using (var transaction = conn.BeginTransaction()) { var command = conn.CreateCommand(); command.CommandText = "[Api].[LogDeviceRequest]"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Transaction = transaction; command.Parameters.AddWithValue(//etc ...