diff --git a/Dapper.EntityFramework.StrongName/Dapper.EntityFramework.StrongName.csproj b/Dapper.EntityFramework.StrongName/Dapper.EntityFramework.StrongName.csproj
index 4207cd180..87e09a1bb 100644
--- a/Dapper.EntityFramework.StrongName/Dapper.EntityFramework.StrongName.csproj
+++ b/Dapper.EntityFramework.StrongName/Dapper.EntityFramework.StrongName.csproj
@@ -4,7 +4,7 @@
Dapper: Entity Framework type handlers (with a strong name)
Extension handlers for entity framework
Marc Gravell;Nick Craver
- net461
+ net462
../Dapper.snk
true
true
diff --git a/Dapper.EntityFramework/Dapper.EntityFramework.csproj b/Dapper.EntityFramework/Dapper.EntityFramework.csproj
index 13310a116..598dcc66c 100644
--- a/Dapper.EntityFramework/Dapper.EntityFramework.csproj
+++ b/Dapper.EntityFramework/Dapper.EntityFramework.csproj
@@ -5,7 +5,7 @@
Dapper entity framework type handlers
1.50.2
Marc Gravell;Nick Craver
- net461
+ net462
orm;sql;micro-orm
diff --git a/Dapper.Rainbow/Dapper.Rainbow.csproj b/Dapper.Rainbow/Dapper.Rainbow.csproj
index dcf0f4e40..6e40fe5f8 100644
--- a/Dapper.Rainbow/Dapper.Rainbow.csproj
+++ b/Dapper.Rainbow/Dapper.Rainbow.csproj
@@ -6,17 +6,18 @@
Trivial micro-orm implemented on Dapper, provides with CRUD helpers.
Sam Saffron
2017 Sam Saffron
- net461;netstandard2.0;net5.0
+ net48;netstandard2.1;net5.0
false
+
-
+
-
+
\ No newline at end of file
diff --git a/Dapper.Rainbow/Database.Async.cs b/Dapper.Rainbow/Database.Async.cs
index cdbf7e41f..67fd8e0df 100644
--- a/Dapper.Rainbow/Database.Async.cs
+++ b/Dapper.Rainbow/Database.Async.cs
@@ -26,7 +26,7 @@ public partial class Table
string colsParams = string.Join(",", paramNames.Select(p => "@" + p));
var sql = "set nocount on insert " + TableName + " (" + cols + ") values (" + colsParams + ") select cast(scope_identity() as int)";
- return (await database.QueryAsync(sql, o).ConfigureAwait(false)).Single();
+ return await database.QueryAsync(sql, o).SingleAsync().ConfigureAwait(false);
}
///
@@ -77,7 +77,7 @@ public virtual Task FirstAsync() =>
/// Asynchronously gets the all rows from this table.
///
/// Data from all table rows.
- public Task> AllAsync() =>
+ public IAsyncEnumerable AllAsync() =>
database.QueryAsync("select * from " + TableName);
}
@@ -97,7 +97,7 @@ public Task ExecuteAsync(string sql, dynamic param = null) =>
/// The SQL to execute.
/// The parameters to use.
/// An enumerable of for the rows fetched.
- public Task> QueryAsync(string sql, dynamic param = null) =>
+ public IAsyncEnumerable QueryAsync(string sql, dynamic param = null) =>
_connection.QueryAsync(sql, param as object, _transaction, _commandTimeout);
///
@@ -194,7 +194,7 @@ public Task> QueryAsyncThe SQL to execute.
/// The parameters to use.
/// Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object>
- public Task> QueryAsync(string sql, dynamic param = null) =>
+ public IAsyncEnumerable QueryAsync(string sql, dynamic param = null) =>
_connection.QueryAsync(sql, param as object, _transaction);
///
diff --git a/Dapper.SqlBuilder/Dapper.SqlBuilder.csproj b/Dapper.SqlBuilder/Dapper.SqlBuilder.csproj
index 74fe251d3..de2def947 100644
--- a/Dapper.SqlBuilder/Dapper.SqlBuilder.csproj
+++ b/Dapper.SqlBuilder/Dapper.SqlBuilder.csproj
@@ -5,17 +5,17 @@
Dapper SqlBuilder component
The Dapper SqlBuilder component, for building SQL queries dynamically.
Sam Saffron, Johan Danforth
- net461;netstandard2.0;net5.0
+ net462;netstandard2.1;net5.0
false
false
-
+
-
+
\ No newline at end of file
diff --git a/Dapper.StrongName/Dapper.StrongName.csproj b/Dapper.StrongName/Dapper.StrongName.csproj
index 023a4eae4..9f85dcde9 100644
--- a/Dapper.StrongName/Dapper.StrongName.csproj
+++ b/Dapper.StrongName/Dapper.StrongName.csproj
@@ -5,7 +5,7 @@
Dapper (Strong Named)
A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc..
Sam Saffron;Marc Gravell;Nick Craver
- net461;netstandard2.0;net5.0
+ net462;netstandard2.1;net5.0
true
true
@@ -18,7 +18,11 @@
$(DefineConstants);PLAT_NO_REMOTING;PLAT_SKIP_LOCALS_INIT
true
-
+
+
+
+
+
diff --git a/Dapper/Dapper.csproj b/Dapper/Dapper.csproj
index 25f87ccf6..4968fa011 100644
--- a/Dapper/Dapper.csproj
+++ b/Dapper/Dapper.csproj
@@ -5,7 +5,7 @@
orm;sql;micro-orm
A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc..
Sam Saffron;Marc Gravell;Nick Craver
- net461;netstandard2.0;net5.0
+ net462;netstandard2.1;net5.0
@@ -15,7 +15,11 @@
$(DefineConstants);PLAT_NO_REMOTING;PLAT_SKIP_LOCALS_INIT
true
-
+
+
+
+
+
diff --git a/Dapper/SqlMapper.Async.cs b/Dapper/SqlMapper.Async.cs
index dba737fc6..7bcba8e36 100644
--- a/Dapper/SqlMapper.Async.cs
+++ b/Dapper/SqlMapper.Async.cs
@@ -19,11 +19,12 @@ public static partial class SqlMapper
/// The SQL to execute for the query.
/// The parameters to pass, if any.
/// The transaction to use, if any.
+ /// Whether to buffer the results in memory.
/// The command timeout (in seconds).
/// The type of command to execute.
/// Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object>
- public static Task> QueryAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null) =>
- QueryAsync(cnn, typeof(DapperRow), new CommandDefinition(sql, param, transaction, commandTimeout, commandType, CommandFlags.Buffered, default));
+ public static IAsyncEnumerable QueryAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, bool buffered = true, int ? commandTimeout = null, CommandType? commandType = null) =>
+ QueryAsync(cnn, typeof(DapperRow), new CommandDefinition(sql, param, transaction, commandTimeout, commandType, buffered ? CommandFlags.Buffered : CommandFlags.None, default));
///
/// Execute a query asynchronously using Task.
@@ -31,7 +32,7 @@ public static Task> QueryAsync(this IDbConnection cnn, stri
/// The connection to query on.
/// The command used to query on this connection.
/// Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object>
- public static Task> QueryAsync(this IDbConnection cnn, CommandDefinition command) =>
+ public static IAsyncEnumerable QueryAsync(this IDbConnection cnn, CommandDefinition command) =>
QueryAsync(cnn, typeof(DapperRow), command);
///
@@ -84,7 +85,7 @@ public static Task QuerySingleOrDefaultAsync(this IDbConnection cnn, Co
/// A sequence of data of ; if a basic type (int, string, etc) is queried then the data from the first column is assumed, otherwise an instance is
/// created per row, and a direct column-name===member-name mapping is assumed (case insensitive).
///
- public static Task> QueryAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null) =>
+ public static IAsyncEnumerable QueryAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null) =>
QueryAsync(cnn, typeof(T), new CommandDefinition(sql, param, transaction, commandTimeout, commandType, CommandFlags.Buffered, default));
///
@@ -195,13 +196,14 @@ public static Task QuerySingleOrDefaultAsync(this IDbConnection cnn, st
/// The SQL to execute for the query.
/// The parameters to pass, if any.
/// The transaction to use, if any.
+ /// Whether to buffer the results in memory.
/// The command timeout (in seconds).
/// The type of command to execute.
/// is null.
- public static Task> QueryAsync(this IDbConnection cnn, Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
+ public static IAsyncEnumerable
diff --git a/tests/Dapper.Tests/MiscTests.cs b/tests/Dapper.Tests/MiscTests.cs
index 4d5dd26c4..4fab07e03 100644
--- a/tests/Dapper.Tests/MiscTests.cs
+++ b/tests/Dapper.Tests/MiscTests.cs
@@ -220,7 +220,7 @@ public async Task TestConversionExceptionMessages()
// List paths
var list = connection.Query(sql);
Assert.Null(Assert.Single(list));
- list = await connection.QueryAsync(sql);
+ list = await connection.QueryAsync(sql).ToListAsync();
Assert.Null(Assert.Single(list));
// Single row paths
@@ -247,7 +247,7 @@ static async Task TestExceptionsAsync(DbConnection connection, string sql, st
ex = Assert.Throws(() => connection.QuerySingleOrDefault(sql));
Assert.Equal(exception, ex.Message);
- ex = await Assert.ThrowsAsync(() => connection.QueryAsync(sql));
+ ex = await Assert.ThrowsAsync(async () => await connection.QueryAsync(sql).ToListAsync());
Assert.Equal(exception, ex.Message);
ex = await Assert.ThrowsAsync(() => connection.QueryFirstAsync(sql));
Assert.Equal(exception, ex.Message);
@@ -1237,8 +1237,10 @@ public async void SO35470588_WrongValuePidValue()
insert TPTable (Value) values (2), (568)");
// fetch the data using the query in the question, then force to a dictionary
- var rows = (await connection.QueryAsync("select * from TPTable").ConfigureAwait(false))
- .ToDictionary(x => x.Pid);
+ var rows =
+ await connection.QueryAsync("select * from TPTable")
+ .ToDictionaryAsync(x => x.Pid)
+ .ConfigureAwait(false);
// check the number of rows
Assert.Equal(2, rows.Count);
diff --git a/tests/Dapper.Tests/ProcedureTests.cs b/tests/Dapper.Tests/ProcedureTests.cs
index 2e320779a..7e5cd906e 100644
--- a/tests/Dapper.Tests/ProcedureTests.cs
+++ b/tests/Dapper.Tests/ProcedureTests.cs
@@ -277,7 +277,8 @@ select 1 as Num
end
end
- exec {tempSPName}");
+ exec {tempSPName}")
+ .ToListAsync();
Assert.Empty(result);
}
diff --git a/tests/Dapper.Tests/Providers/SqliteTests.cs b/tests/Dapper.Tests/Providers/SqliteTests.cs
index a5aeb086f..87594dbb4 100644
--- a/tests/Dapper.Tests/Providers/SqliteTests.cs
+++ b/tests/Dapper.Tests/Providers/SqliteTests.cs
@@ -74,9 +74,15 @@ public async Task Issue466_SqliteHatesOptimizations_Async()
using (var connection = GetSQLiteConnection())
{
SqlMapper.ResetTypeHandlers();
- var row = (await connection.QueryAsync("select 42 as Id").ConfigureAwait(false)).First();
+ var row =
+ await connection.QueryAsync("select 42 as Id")
+ .FirstAsync()
+ .ConfigureAwait(false);
Assert.Equal(42, row.Id);
- row = (await connection.QueryAsync("select 42 as Id").ConfigureAwait(false)).First();
+ row =
+ await connection.QueryAsync("select 42 as Id")
+ .FirstAsync()
+ .ConfigureAwait(false);
Assert.Equal(42, row.Id);
SqlMapper.ResetTypeHandlers();