'QueryAsync causes object cycle with MultipleActiveResultSets set on in connection string

I can't figure out how to use the queryAsync from Dapper in c#

My connection string has MultipleActiveResultSets set to true because without it I get an exceptions saying that the connection can't handle multiple active results set witch is confusing because I only return 1 table from my query.

Any way. Set it to true and now I get this

"System.Text.Json.JsonException: A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 32. Consider using ReferenceHandler.Preserve on JsonSerializerOptions to support cycles."

        public async Task<IEnumerable<T>> GetSellers<T>(string sellerTableName)
        {
            string query = @"exec spSeller_Get @tableName";
            
            var list = await Connection.QueryAsync<T>(query, new { tableName = sellerTableName }, transaction: Transaction, commandType: CommandType.Text);
            return list.ToList();
        }

Also if I set commandType to stored procedure it can't find the stored procedure but on text works fine.

Note that if I use Query insted of QueryAsync everything works fine.

P.S the function GetSellers is called from controller with sellerTableName send to that endpoint



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source