Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Post[] posts = await connectionFactory
## Install

```sh
dotnet add package Open.Database.Extensions.Core --prerelease
dotnet add package Open.Database.Extensions.Core
dotnet add package Microsoft.Data.Sqlite
```

Expand All @@ -94,7 +94,7 @@ dotnet add package Microsoft.Data.Sqlite
| `Open.Database.Extensions.Dataflow` | Rows into TPL Dataflow blocks. |
| `Open.Database.Extensions.MSSqlClient` | `SqlConnectionFactory` and SQL Server specializations on `Microsoft.Data.SqlClient`. |

Targets: `netstandard2.0`, `netstandard2.1`, `net10.0` and `net11.0` (`MSSqlClient`: `net472`, `net10.0` and `net11.0`). Version 11 is a release candidate.
Targets: `netstandard2.0`, `netstandard2.1`, `net10.0` and `net11.0` (`MSSqlClient`: `net472`, `net10.0` and `net11.0`).

## Performance

Expand Down
9 changes: 9 additions & 0 deletions Source/Channel/Open.Database.Extensions.Channel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.403" PrivateAssets="All" />
</ItemGroup>

<!-- Public API surface tracking, as on Core: enabled on the modern targets only (the public API differs on the netstandard shims).
The package's own targets add PublicAPI.Shipped.txt and PublicAPI.Unshipped.txt as AdditionalFiles when they sit next to the project. -->
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0' or '$(TargetFramework)' == 'net11.0'">
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<!-- PrivateAssets: Core's source generator and build targets reach this package's consumers too (NuGet keeps them back by default). -->
<ProjectReference Include="..\Core\Open.Database.Extensions.Core.csproj" PrivateAssets="contentfiles" />
Expand Down
18 changes: 18 additions & 0 deletions Source/Channel/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#nullable enable
Open.Database.Extensions.ChannelDbExtensions
static Open.Database.Extensions.ChannelDbExtensions.ToBoundedChannel<T>(this Open.Database.Extensions.IMappedQuery<T>! source, int capacity, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Channels.Channel<T>!
static Open.Database.Extensions.ChannelDbExtensions.ToBoundedChannelReader<T>(this Open.Database.Extensions.IMappedQuery<T>! source, int capacity, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Channels.ChannelReader<T>!
static Open.Database.Extensions.ChannelDbExtensions.ToChannel<T>(this Open.Database.Extensions.IMappedQuery<T>! source, bool singleReader, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Channels.Channel<T>!
static Open.Database.Extensions.ChannelDbExtensions.ToChannel<T>(this Open.Database.Extensions.IMappedQuery<T>! source, out System.Threading.Tasks.Task<long>! readCount, bool singleReader, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Channels.Channel<T>!
static Open.Database.Extensions.ChannelDbExtensions.ToChannel<T>(this Open.Database.Extensions.IMappedQuery<T>! source, out System.Threading.Tasks.Task<long>! readCount, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Channels.Channel<T>!
static Open.Database.Extensions.ChannelDbExtensions.ToChannel<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Channels.Channel<T>!
static Open.Database.Extensions.ChannelDbExtensions.ToChannel<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.Channels.Channel<T>! channel, bool complete, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<long>
static Open.Database.Extensions.ChannelDbExtensions.ToChannel<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.Channels.Channel<T>! channel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<long>
static Open.Database.Extensions.ChannelDbExtensions.ToChannel<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.Channels.ChannelWriter<T>! writer, bool complete, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<long>
static Open.Database.Extensions.ChannelDbExtensions.ToChannel<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.Channels.ChannelWriter<T>! writer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<long>
static Open.Database.Extensions.ChannelDbExtensions.ToChannelHoldingConnection<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.Channels.Channel<T>! channel, System.TimeSpan stallTimeout, bool complete, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<long>
static Open.Database.Extensions.ChannelDbExtensions.ToChannelHoldingConnection<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.Channels.Channel<T>! channel, System.TimeSpan stallTimeout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<long>
static Open.Database.Extensions.ChannelDbExtensions.ToChannelHoldingConnection<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.Channels.ChannelWriter<T>! writer, System.TimeSpan stallTimeout, bool complete, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<long>
static Open.Database.Extensions.ChannelDbExtensions.ToChannelHoldingConnection<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.Channels.ChannelWriter<T>! writer, System.TimeSpan stallTimeout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<long>
static Open.Database.Extensions.ChannelDbExtensions.ToChannelReader<T>(this Open.Database.Extensions.IMappedQuery<T>! source, bool singleReader, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Channels.ChannelReader<T>!
static Open.Database.Extensions.ChannelDbExtensions.ToChannelReader<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Channels.ChannelReader<T>!
1 change: 1 addition & 0 deletions Source/Channel/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
2 changes: 1 addition & 1 deletion Source/Channel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Read a query's rows into a `System.Threading.Channels` channel that any consumer or pipeline can read. The query fills the channel in the background while your consumer works, and the connection is closed when the last row is read, however slowly the consumer reads.

```sh
dotnet add package Open.Database.Extensions.Channel --prerelease
dotnet add package Open.Database.Extensions.Channel
dotnet add package Open.ChannelExtensions # optional: Transform, Batch, Join and ReadAll for the rows
```

Expand Down
19 changes: 10 additions & 9 deletions Source/Core/Extensions/DataRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,19 @@ public static IEnumerable<ColumnOrdinal> MatchingOrdinals(this IDataRecord recor
// Return the first actual column, in record order, of each requested name.
return FirstColumnOfEachRequestedName(actual, requested);
}
else

// Map actual columns case-insensitively so the requested order can be preserved.
// The first column of a name stays; a later column of the same name is skipped.
var actualColumns = new Dictionary<string, ColumnOrdinal>(StringComparer.OrdinalIgnoreCase);
foreach (ColumnOrdinal m in actual)
{
// Map actual columns case-insensitively so the requested order can be preserved.
// The first column of a name stays; a later column of the same name is skipped.
var actualColumns = new Dictionary<string, ColumnOrdinal>(StringComparer.OrdinalIgnoreCase);
foreach (ColumnOrdinal m in actual)
actualColumns.TryAdd(m.Name, m);
return requestedNames
.Where(actualColumns.ContainsKey)
.Select(c => actualColumns[c]);
actualColumns.TryAdd(m.Name, m);
}

return requestedNames
.Where(actualColumns.ContainsKey)
.Select(c => actualColumns[c]);

static IEnumerable<ColumnOrdinal> FirstColumnOfEachRequestedName(
IEnumerable<ColumnOrdinal> actual,
HashSet<string> requested)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You write the SQL. Open.Database.Extensions (ODX) writes the ADO.NET around it: the connection, the parameters, the read loop, the mapping to your types and the disposal. It works with any ADO.NET provider and holds a connection open only while a query needs it.

```sh
dotnet add package Open.Database.Extensions.Core --prerelease
dotnet add package Open.Database.Extensions.Core
dotnet add package Microsoft.Data.Sqlite # your provider; SQLite is used below
```

Expand Down
9 changes: 9 additions & 0 deletions Source/Dataflow/Open.Database.Extensions.Dataflow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="10.0.14" />
</ItemGroup>

<!-- Public API surface tracking, as on Core: enabled on the modern targets only (the public API differs on the netstandard shims).
The package's own targets add PublicAPI.Shipped.txt and PublicAPI.Unshipped.txt as AdditionalFiles when they sit next to the project. -->
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0' or '$(TargetFramework)' == 'net11.0'">
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<!-- PrivateAssets: Core's source generator and build targets reach this package's consumers too (NuGet keeps them back by default). -->
<ProjectReference Include="..\Core\Open.Database.Extensions.Core.csproj" PrivateAssets="contentfiles" />
Expand Down
8 changes: 8 additions & 0 deletions Source/Dataflow/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#nullable enable
Open.Database.Extensions.DataflowExtensions
static Open.Database.Extensions.DataflowExtensions.AsSourceBlock<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Dataflow.IReceivableSourceBlock<T>!
static Open.Database.Extensions.DataflowExtensions.AsSourceBlock<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.Tasks.Dataflow.DataflowBlockOptions! options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Dataflow.IReceivableSourceBlock<T>!
static Open.Database.Extensions.DataflowExtensions.ToTargetBlock<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.Tasks.Dataflow.ITargetBlock<T>! target, bool complete, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<long>
static Open.Database.Extensions.DataflowExtensions.ToTargetBlock<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.Tasks.Dataflow.ITargetBlock<T>! target, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<long>
static Open.Database.Extensions.DataflowExtensions.ToTargetBlockHoldingConnection<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.Tasks.Dataflow.ITargetBlock<T>! target, System.TimeSpan stallTimeout, bool complete, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<long>
static Open.Database.Extensions.DataflowExtensions.ToTargetBlockHoldingConnection<T>(this Open.Database.Extensions.IMappedQuery<T>! source, System.Threading.Tasks.Dataflow.ITargetBlock<T>! target, System.TimeSpan stallTimeout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<long>
1 change: 1 addition & 0 deletions Source/Dataflow/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
2 changes: 1 addition & 1 deletion Source/Dataflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Send a query's rows into a TPL Dataflow pipeline you build. The blocks, their schedulers and their priorities stay yours; the query is read at the provider's pace, and the connection is closed when the read ends.

```sh
dotnet add package Open.Database.Extensions.Dataflow --prerelease
dotnet add package Open.Database.Extensions.Dataflow
```

```cs
Expand Down
2 changes: 0 additions & 2 deletions Source/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

<VersionPrefix>11.0.0</VersionPrefix>
<VersionSuffix Condition="'$(Configuration)' == 'Debug'">debug</VersionSuffix>
<!-- Release candidate line: delete this element (or pass -p:VersionSuffix=) to build the stable 11.0.0 packages. -->
<VersionSuffix Condition="'$(Configuration)' != 'Debug'">rc.18</VersionSuffix>

<!-- A package built on a developer machine must not carry that machine's folder names. In a Release build the SDK maps the repository root to a neutral prefix
in every path it embeds: the source files, the debug-symbol path inside each dll, and the Source Link mapping inside the symbols. -->
Expand Down
2 changes: 1 addition & 1 deletion Source/MSSqlClient/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
SQL Server for Open.Database.Extensions: `SqlConnectionFactory`, stored procedures whose parameters are named from your arguments, and output parameters read into a model, on `Microsoft.Data.SqlClient`. It brings [Open.Database.Extensions.Core](https://www.nuget.org/packages/Open.Database.Extensions.Core/) and the provider with it, so it is the only package to install.

```sh
dotnet add package Open.Database.Extensions.MSSqlClient --prerelease
dotnet add package Open.Database.Extensions.MSSqlClient
```

```cs
Expand Down
4 changes: 2 additions & 2 deletions docsite/articles/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Most applications need one package. The others add integrations.
| `Open.Database.Extensions.Dataflow` | [Reading into dataflow blocks](channels-and-dataflow.md) | same |
| `Open.Database.Extensions.MSSqlClient` | `SqlConnectionFactory` and SQL Server specializations on `Microsoft.Data.SqlClient` | `net472`, `net10.0`, `net11.0` |

.NET 8 and .NET 9 applications use the `netstandard2.1` build; .NET Framework applications use `netstandard2.0` (or `net472` for the SQL Server package). Version 11 is a release candidate, so ask for prereleases:
.NET 8 and .NET 9 applications use the `netstandard2.1` build; .NET Framework applications use `netstandard2.0` (or `net472` for the SQL Server package). To use it, add the Core package, which the other packages build on:

```sh
dotnet add package Open.Database.Extensions.Core --prerelease
dotnet add package Open.Database.Extensions.Core
```

Core does not reference any database provider. Bring your own: the examples in this guide use `Microsoft.Data.Sqlite` so that you can run them without a server:
Expand Down
Loading