Skip to content

Commit 4bb91dc

Browse files
Updated references.
1 parent cad3984 commit 4bb91dc

9 files changed

Lines changed: 69 additions & 18 deletions

Source/Channel/Open.Database.Extensions.Channel.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageTags>ado;ado extensions;sql;connection factory;extensions;channel;channels</PackageTags>
1515
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1616
<RepositoryType>git</RepositoryType>
17-
<Version>7.0.1</Version>
17+
<Version>7.0.4</Version>
1818
<PackageReleaseNotes></PackageReleaseNotes>
1919
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2020
<IncludeSymbols>true</IncludeSymbols>
@@ -28,8 +28,8 @@
2828

2929
<ItemGroup>
3030
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
31-
<PackageReference Include="Open.ChannelExtensions" Version="6.0.0" />
32-
<PackageReference Include="Open.Database.Extensions.Core" Version="7.0.1" />
31+
<PackageReference Include="Open.ChannelExtensions" Version="6.1.0" />
32+
<PackageReference Include="Open.Database.Extensions.Core" Version="7.0.4" />
3333
</ItemGroup>
3434

3535
<ItemGroup>

Source/Core/Extensions/Command._.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,26 @@ public static T ExecuteReader<T>(this IDbCommand command, Func<IDataReader, T> t
233233
return transform(reader);
234234
}
235235

236+
/// <summary>
237+
/// If the <paramref name="command"/> is derived from <see cref="DbCommand"/>, this will call <see cref="DbCommand.ExecuteReaderAsync(CommandBehavior, CancellationToken)"/>;
238+
/// otherwise it will call <see cref="IDbCommand.ExecuteReader(CommandBehavior)"/>.
239+
/// </summary>
240+
/// <param name="command">The <see cref="DbCommand"/> to generate a reader from.</param>
241+
/// <param name="behavior">The behavior to use with the data reader.</param>
242+
/// <param name="cancellationToken">The cancellation token.</param>
243+
public static async ValueTask<IDataReader> ExecuteReaderAsync(this IDbCommand command,
244+
CommandBehavior behavior = CommandBehavior.Default,
245+
CancellationToken cancellationToken = default)
246+
{
247+
if (command is null) throw new ArgumentNullException(nameof(command));
248+
Contract.EndContractBlock();
249+
250+
return command is DbCommand c
251+
? await c.ExecuteReaderAsync(behavior, cancellationToken).ConfigureAwait(true)
252+
: command.ExecuteReader(behavior);
253+
}
254+
255+
236256
/// <summary>
237257
/// Asynchronously executes a reader on a command with a handler function.
238258
/// </summary>

Source/Core/Extensions/Connection.EnsureOpen.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,37 @@ public static ValueTask<ConnectionState> EnsureOpenAsync(
7373
=> connection.EnsureOpenAsync(true, cancellationToken);
7474

7575
/// <inheritdoc cref="EnsureOpenAsync(DbConnection, bool, CancellationToken)"/>
76-
internal static async ValueTask<ConnectionState> EnsureOpenAsync(
76+
public static async ValueTask<ConnectionState> EnsureOpenAsync(
7777
this IDbConnection connection,
78-
CancellationToken cancellationToken)
78+
bool configureAwait = true,
79+
CancellationToken cancellationToken = default)
7980
{
8081
if (connection is DbConnection c)
81-
return await c.EnsureOpenAsync(true, cancellationToken).ConfigureAwait(true);
82+
return await c.EnsureOpenAsync(configureAwait, cancellationToken).ConfigureAwait(configureAwait);
8283

8384
cancellationToken.ThrowIfCancellationRequested();
8485
return connection.EnsureOpen();
8586
}
87+
88+
/// <inheritdoc cref="EnsureOpenAsync(DbConnection, bool, CancellationToken)"/>
89+
public static ValueTask<ConnectionState> EnsureOpenAsync(
90+
this IDbConnection connection,
91+
CancellationToken cancellationToken)
92+
=> EnsureOpenAsync(connection, true, cancellationToken);
93+
94+
/// <summary>
95+
/// If the <paramref name="connection"/> derives from <see cref="DbConnection"/>, this will call <see cref="DbConnection.OpenAsync(CancellationToken)"/>;
96+
/// otherwise it will call <see cref="IDbConnection.Open()"/>.
97+
/// </summary>
98+
/// <inheritdoc cref="EnsureOpenAsync(DbConnection, bool, CancellationToken)"/>
99+
public static async ValueTask OpenAsync(
100+
this IDbConnection connection,
101+
bool configureAwait = true,
102+
CancellationToken cancellationToken = default)
103+
{
104+
if (connection is DbConnection c)
105+
await c.OpenAsync(cancellationToken).ConfigureAwait(configureAwait);
106+
107+
connection.Open();
108+
}
86109
}

Source/Core/Open.Database.Extensions.Core.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageTags>ado;ado extensions;sql;connection factory;extensions;</PackageTags>
1515
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1616
<RepositoryType>git</RepositoryType>
17-
<Version>7.0.2</Version>
17+
<Version>7.0.4</Version>
1818
<PackageReleaseNotes></PackageReleaseNotes>
1919
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2020
<IncludeSymbols>true</IncludeSymbols>
@@ -32,7 +32,7 @@
3232
</ItemGroup>
3333

3434
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
35-
<PackageReference Include="System.Memory" Version="4.5.4" />
35+
<PackageReference Include="System.Memory" Version="4.5.5" />
3636
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
3737
</ItemGroup>
3838

Source/Dataflow/Open.Database.Extensions.Dataflow.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageTags>ado;ado extensions;dataflow;data;database</PackageTags>
1515
<RepositoryType>git</RepositoryType>
1616
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
17-
<Version>7.0.1</Version>
17+
<Version>7.0.4</Version>
1818
<PackageReleaseNotes></PackageReleaseNotes>
1919
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2020
<IncludeSymbols>true</IncludeSymbols>
@@ -28,7 +28,7 @@
2828

2929
<ItemGroup>
3030
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
31-
<PackageReference Include="Open.Database.Extensions.Core" Version="7.0.1" />
31+
<PackageReference Include="Open.Database.Extensions.Core" Version="7.0.4" />
3232
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="6.*" />
3333
</ItemGroup>
3434

Source/Extensions/Open.Database.Extensions.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageTags>ado;ado extensions;sql;connection factory;extensions;</PackageTags>
1515
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1616
<RepositoryType>git</RepositoryType>
17-
<Version>7.0.0</Version>
17+
<Version>7.0.4</Version>
1818
<PackageReleaseNotes></PackageReleaseNotes>
1919
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2020
<IncludeSymbols>true</IncludeSymbols>
@@ -24,9 +24,9 @@
2424
</PropertyGroup>
2525

2626
<ItemGroup>
27-
<PackageReference Include="Open.Database.Extensions.Channel" Version="7.0.0" />
28-
<PackageReference Include="Open.Database.Extensions.Dataflow" Version="7.0.0" />
29-
<PackageReference Include="Open.Database.Extensions.SqlClient" Version="7.0.0" />
27+
<PackageReference Include="Open.Database.Extensions.Channel" Version="7.0.1" />
28+
<PackageReference Include="Open.Database.Extensions.Dataflow" Version="7.0.1" />
29+
<PackageReference Include="Open.Database.Extensions.SqlClient" Version="7.0.2" />
3030
</ItemGroup>
3131

3232
<ItemGroup>

Source/SqlClient/Open.Database.Extensions.SqlClient.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageTags>ado;ado extensions;sql;connection factory;extensions;</PackageTags>
1515
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1616
<RepositoryType>git</RepositoryType>
17-
<Version>7.0.2</Version>
17+
<Version>7.0.4</Version>
1818
<PackageReleaseNotes></PackageReleaseNotes>
1919
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2020
<IncludeSymbols>true</IncludeSymbols>
@@ -28,7 +28,7 @@
2828

2929
<ItemGroup>
3030
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
31-
<PackageReference Include="Open.Database.Extensions.Core" Version="7.0.2" />
31+
<PackageReference Include="Open.Database.Extensions.Core" Version="7.0.4" />
3232
<PackageReference Include="System.Data.SqlClient" Version="4.*" />
3333
</ItemGroup>
3434

Tests/Open.Database.Extensions.Core.Tests/Basic.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using NSubstitute;
22
using System;
33
using System.Data;
4+
using System.Threading.Tasks;
45
using Xunit;
56

67
namespace Open.Database.Extensions.Core.Tests;
@@ -16,7 +17,14 @@ public void ExpressiveCommandValidation()
1617
return conn;
1718
});
1819

20+
1921
Assert.Throws<ArgumentNullException>(() => factory.Command(null));
2022
Assert.Throws<ArgumentException>(() => factory.Command(string.Empty));
2123
}
24+
25+
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Compile test.")]
26+
static async Task AmbiguityValidation(IDbCommand command)
27+
{
28+
await command.Connection.EnsureOpenAsync();
29+
}
2230
}

Tests/Open.Database.Extensions.Core.Tests/Open.Database.Extensions.Core.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
1111
<PackageReference Include="NSubstitute" Version="4.3.0" />
1212
<PackageReference Include="xunit" Version="2.4.1" />
13-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
</PackageReference>

0 commit comments

Comments
 (0)