Mini Profiler SQL Timings are 0.0 ms MySQL Using ExecuteReaderAsync()


#1

I use Mini Profiler with EF6 and all operations report my timings. However for some really complicated queries I use ADO.Net inline with “ProfiledDbConnection”.

My project is .NET 4.5.2 (pre-standard)
Mini Profiler version is 3.2.0.157

When I run Scalar operations I get STEP timings and SQL timings fine.
If I run Reader operations I get STEP timings but no SQL timings.

SharedScreenshot

My code is almost exactly the same for each operation…
The problem is with…

cmd.ExecuteScalarAsync() - Works
cmd.ExecuteReaderAsync() - Does not work

My code…

            using (var step1 = MiniProfiler.Current.Step("Get Verified Work Amendments Data SQL"))
            {
                using (var mySqlCon = new MySqlConnection(connectionString: ConfigurationManager.ConnectionStrings["MySqlConnectionString"].ConnectionString))
                {
                    using (var conn = new ProfiledDbConnection(mySqlCon, MiniProfiler.Current))
                    {
                        var query = Query(membershipType, fieldToSort, ascending, false, skip, take,
                                          songTitle, songUniqueCode,
                                          catalogueName, catalogueUniqueCode,
                                          accountName, accountUniqueCode);

                        var cmd = conn.CreateCommand();
                        cmd.CommandText = query;

                        var param1 = cmd.CreateParameter();
                        param1.DbType = System.Data.DbType.String;
                        param1.ParameterName = TenantId;
                        param1.Value = tenantId;
                        cmd.Parameters.Add(param1);

                        var param2 = cmd.CreateParameter();
                        param2.DbType = System.Data.DbType.String;
                        param2.ParameterName = MembershipId;
                        param2.Value = membershipId;
                        cmd.Parameters.Add(param2);

                        var param3 = cmd.CreateParameter();
                        param3.DbType = System.Data.DbType.String;
                        param3.ParameterName = SongCode;
                        param3.Value = songUniqueCode;
                        cmd.Parameters.Add(param3);

                        var param4 = cmd.CreateParameter();
                        param4.DbType = System.Data.DbType.String;
                        param4.ParameterName = SongTitle;
                        param4.Value = songTitle + "%";
                        cmd.Parameters.Add(param4);

                        var param5 = cmd.CreateParameter();
                        param5.DbType = System.Data.DbType.String;
                        param5.ParameterName = CatalogueUniqueCode;
                        param5.Value = catalogueUniqueCode;
                        cmd.Parameters.Add(param5);

                        var param6 = cmd.CreateParameter();
                        param6.DbType = System.Data.DbType.String;
                        param6.ParameterName = CatalogueName;
                        param6.Value = catalogueName + "%";
                        cmd.Parameters.Add(param6);

                        var param7 = cmd.CreateParameter();
                        param7.DbType = System.Data.DbType.String;
                        param7.ParameterName = AccountUniqueCode;
                        param7.Value = accountUniqueCode;
                        cmd.Parameters.Add(param7);

                        var param8 = cmd.CreateParameter();
                        param8.DbType = System.Data.DbType.String;
                        param8.ParameterName = AccountName;
                        param8.Value = accountName + "%";
                        cmd.Parameters.Add(param8);

                        var param9 = cmd.CreateParameter();
                        param9.DbType = System.Data.DbType.Int32;
                        param9.ParameterName = Skip;
                        param9.Value = skip;
                        cmd.Parameters.Add(param9);

                        var param10 = cmd.CreateParameter();
                        param10.DbType = System.Data.DbType.Int32;
                        param10.ParameterName = Take;
                        param10.Value = take;
                        cmd.Parameters.Add(param10);

                        await conn.OpenAsync();

                        var reader = await cmd.ExecuteReaderAsync();
                        while (await reader.ReadAsync())
                        { 
                            var record = new ReadModels.VerifiedWorksForShipmentDisplay
                            {
                                SongID = reader.GetGuid(0),
                                SongUniqueCode = reader.GetString(1),
                                SongTitle = reader.GetString(2),
                                SongCreatedDate = reader.GetDateTime(3),
                                ArtistAccountUniqueCode = reader.GetString(4),
                                CatalogueName = reader.GetString(5),

                                IsDeactivated = reader.GetBoolean(6)
                            };

                            workAmendments.Add(record);
                        }
                    }
                    return workAmendments;
                }
            }

However this Scalar does work, code…

            using (var step1 = MiniProfiler.Current.Step("Get Verified Work Amendments Count SQL"))
            {
                using (var mySqlCon = new MySqlConnection(connectionString: ConfigurationManager.ConnectionStrings["MySqlConnectionString"].ConnectionString))
                {
                    var count = 0;

                    using (var conn = new ProfiledDbConnection(mySqlCon, MiniProfiler.Current))
                    {
                        var query = Query(membershipType, null, null, true, 0, 0,
                            songTitle, songUniqueCode,
                            catalogueName, catalogueUniqueCode,
                            accountName, accountUniqueCode);
                        var cmd = conn.CreateCommand();
                        cmd.CommandText = query;

                        var param1 = cmd.CreateParameter();
                        param1.DbType = System.Data.DbType.String;
                        param1.ParameterName = TenantId;
                        param1.Value = tenantId;
                        cmd.Parameters.Add(param1);

                        var param2 = cmd.CreateParameter();
                        param2.DbType = System.Data.DbType.String;
                        param2.ParameterName = MembershipId;
                        param2.Value = membershipId;
                        cmd.Parameters.Add(param2);

                        var param3 = cmd.CreateParameter();
                        param3.DbType = System.Data.DbType.String;
                        param3.ParameterName = SongCode;
                        param3.Value = songUniqueCode;
                        cmd.Parameters.Add(param3);

                        var param4 = cmd.CreateParameter();
                        param4.DbType = System.Data.DbType.String;
                        param4.ParameterName = SongTitle;
                        param4.Value = songTitle + "%";
                        cmd.Parameters.Add(param4);

                        var param5 = cmd.CreateParameter();
                        param5.DbType = System.Data.DbType.String;
                        param5.ParameterName = CatalogueUniqueCode;
                        param5.Value = catalogueUniqueCode;
                        cmd.Parameters.Add(param5);

                        var param6 = cmd.CreateParameter();
                        param6.DbType = System.Data.DbType.String;
                        param6.ParameterName = CatalogueName;
                        param6.Value = catalogueName + "%";
                        cmd.Parameters.Add(param6);

                        var param7 = cmd.CreateParameter();
                        param7.DbType = System.Data.DbType.String;
                        param7.ParameterName = AccountUniqueCode;
                        param7.Value = accountUniqueCode;
                        cmd.Parameters.Add(param7);

                        var param8 = cmd.CreateParameter();
                        param8.DbType = System.Data.DbType.String;
                        param8.ParameterName = AccountName;
                        param8.Value = accountName + "%";
                        cmd.Parameters.Add(param8);

                        var param9 = cmd.CreateParameter();
                        param9.DbType = System.Data.DbType.Int32;
                        param9.ParameterName = Skip;
                        param9.Value = 0;
                        cmd.Parameters.Add(param9);

                        var param10 = cmd.CreateParameter();
                        param10.DbType = System.Data.DbType.Int32;
                        param10.ParameterName = Take;
                        param10.Value = 0;
                        cmd.Parameters.Add(param10);

                        await conn.OpenAsync();

                        count = Convert.ToInt32(await cmd.ExecuteScalarAsync());
                    }
                    return count;
                }
            }

Is this a bug in MiniProfiler?