Skip to content

Unbuffered QueryAsnyc multi-mapping throws an InvalidOperationException  #596

Description

@mburbea
using(varconn=newSqlConnection(appToken.ConnectionString)){conn.Open();varret=conn.Query("select a='dog',b=3",(stringa,intb)=>a+b,splitOn:"b",buffered:false);Console.WriteLine(string.Join("",ret));ret=conn.QueryAsync("select a='dog',b=3",(stringa,intb)=>a+b,splitOn:"b",buffered:false).Result;Console.WriteLine(string.Join("",ret));}

The call to Query returns dog3, the QueryAsync throws the following exception:

System.InvalidOperationException was unhandled
HResult=-2146233079
Message=Invalid attempt to call FieldCount when reader is closed.
Source=System.Data
StackTrace:
at System.Data.SqlClient.SqlDataReader.get_FieldCount()
at Dapper.SqlMapper.GetColumnHash(IDataReader reader, Int32 startBound, Int32 length)
at Dapper.SqlMapper.<MultiMapImpl>d__140`8.MoveNext()
at System.String.Join(String separator, IEnumerable`1 values)
at Program.Main(String[] args) in 

The store procedure I am calling takes a while to execute and I'd rather let it be called async before I start streaming data out of the query.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    v3.0Changes awaiting the next breaking release

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions