Skip to content

Commit 23c4c53

Browse files
committed
Merge pull request #416 from StackExchange/Issue281
Fix for #281 - Change CommandBehavior on ExecuteReaderAsync to match sync version
2 parents 52b1ccb + 6b848fa commit 23c4c53

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Dapper.Tests/Tests.Async.cs

+13
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,19 @@ select @@Name
734734
", new Product { Id = 1 })).Single();
735735
id.IsEqualTo(2);
736736
}
737+
738+
[Fact]
739+
public async Task Issue1281_DataReaderOutOfOrderAsync()
740+
{
741+
using (var reader = await connection.ExecuteReaderAsync("Select 0, 1, 2"))
742+
{
743+
reader.Read().IsTrue();
744+
reader.GetInt32(2).IsEqualTo(2);
745+
reader.GetInt32(0).IsEqualTo(0);
746+
reader.GetInt32(1).IsEqualTo(1);
747+
reader.Read().IsFalse();
748+
}
749+
}
737750
}
738751
}
739752
#endif

Dapper/SqlMapper.Async.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ private static async Task<IDataReader> ExecuteReaderImplAsync(IDbConnection cnn,
721721
{
722722
cmd = (DbCommand)command.SetupCommand(cnn, paramReader);
723723
if (wasClosed) await ((DbConnection)cnn).OpenAsync(command.CancellationToken).ConfigureAwait(false);
724-
var reader = await cmd.ExecuteReaderAsync(GetBehavior(wasClosed, CommandBehavior.SequentialAccess), command.CancellationToken).ConfigureAwait(false);
724+
var reader = await cmd.ExecuteReaderAsync(GetBehavior(wasClosed, CommandBehavior.Default), command.CancellationToken).ConfigureAwait(false);
725725
wasClosed = false;
726726
return reader;
727727
}

0 commit comments

Comments
 (0)