Skip to content
Open
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
3 changes: 3 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ jobs:
if ($apiPages -lt 100) { throw "Only $apiPages API pages were generated" }
"Site has $apiPages API pages."

- name: Check the package READMEs (banner, image hosts, one identical packages table)
run: ./docsite/tools/check-readmes.ps1

- name: Check the links (a broken page, file or anchor fails the run; an external link fails it only on a hard 404 or 410)
run: ./docsite/tools/check-links.ps1

Expand Down
2 changes: 1 addition & 1 deletion Source/Channel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ Brings [Open.Database.Extensions.Core](https://www.nuget.org/packages/Open.Datab
| **Open.Database.Extensions.Channel** (this package) | Rows into `System.Threading.Channels`. | netstandard2.0, netstandard2.1, net10.0, net11.0 |
| [Open.Database.Extensions.Dataflow](https://www.nuget.org/packages/Open.Database.Extensions.Dataflow/) | Rows into TPL Dataflow blocks. | netstandard2.0, netstandard2.1, net10.0, net11.0 |

Each of the other packages brings Core with it. .NET 8 and .NET 9 use the netstandard2.1 build.
Each of the other packages brings Core with it. .NET 8 and .NET 9 use the netstandard2.1 build; MSSqlClient needs .NET 10 or later on modern .NET.

[Documentation](https://open-net-libraries.github.io/Open.Database.Extensions/) · [API reference](https://open-net-libraries.github.io/Open.Database.Extensions/api/index.html) · [Source and issues](https://github.com/Open-NET-Libraries/Open.Database.Extensions) · MIT license
2 changes: 1 addition & 1 deletion Source/Core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Already have a connection or a transaction? Pass it to `Using(...)`, or start fr
| [Open.Database.Extensions.Channel](https://www.nuget.org/packages/Open.Database.Extensions.Channel/) | Rows into `System.Threading.Channels`. | netstandard2.0, netstandard2.1, net10.0, net11.0 |
| [Open.Database.Extensions.Dataflow](https://www.nuget.org/packages/Open.Database.Extensions.Dataflow/) | Rows into TPL Dataflow blocks. | netstandard2.0, netstandard2.1, net10.0, net11.0 |

Each of the other packages brings Core with it. .NET 8 and .NET 9 use the netstandard2.1 build.
Each of the other packages brings Core with it. .NET 8 and .NET 9 use the netstandard2.1 build; MSSqlClient needs .NET 10 or later on modern .NET.

**Coming from v10?** Version 11 is a significant break, mainly in how typed results are mapped and returned. See the [migration guide](https://open-net-libraries.github.io/Open.Database.Extensions/articles/whats-new-11.html).

Expand Down
2 changes: 1 addition & 1 deletion Source/Dataflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ Brings [Open.Database.Extensions.Core](https://www.nuget.org/packages/Open.Datab
| [Open.Database.Extensions.Channel](https://www.nuget.org/packages/Open.Database.Extensions.Channel/) | Rows into `System.Threading.Channels`. | netstandard2.0, netstandard2.1, net10.0, net11.0 |
| **Open.Database.Extensions.Dataflow** (this package) | Rows into TPL Dataflow blocks. | netstandard2.0, netstandard2.1, net10.0, net11.0 |

Each of the other packages brings Core with it. .NET 8 and .NET 9 use the netstandard2.1 build.
Each of the other packages brings Core with it. .NET 8 and .NET 9 use the netstandard2.1 build; MSSqlClient needs .NET 10 or later on modern .NET.

[Documentation](https://open-net-libraries.github.io/Open.Database.Extensions/) · [API reference](https://open-net-libraries.github.io/Open.Database.Extensions/api/index.html) · [Source and issues](https://github.com/Open-NET-Libraries/Open.Database.Extensions) · MIT license
2 changes: 1 addition & 1 deletion Source/Extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ var connectionFactory = new DbConnectionFactory<SqliteConnection>(
| [Open.Database.Extensions.Channel](https://www.nuget.org/packages/Open.Database.Extensions.Channel/) | Rows into `System.Threading.Channels`. | netstandard2.0, netstandard2.1, net10.0, net11.0 |
| [Open.Database.Extensions.Dataflow](https://www.nuget.org/packages/Open.Database.Extensions.Dataflow/) | Rows into TPL Dataflow blocks. | netstandard2.0, netstandard2.1, net10.0, net11.0 |

Each of the other packages brings Core with it. .NET 8 and .NET 9 use the netstandard2.1 build.
Each of the other packages brings Core with it. .NET 8 and .NET 9 use the netstandard2.1 build; MSSqlClient needs .NET 10 or later on modern .NET.

[Documentation](https://open-net-libraries.github.io/Open.Database.Extensions/) · [Getting started](https://open-net-libraries.github.io/Open.Database.Extensions/articles/getting-started.html) · [Coming from Dapper](https://open-net-libraries.github.io/Open.Database.Extensions/articles/coming-from-dapper.html) · [Performance](https://open-net-libraries.github.io/Open.Database.Extensions/articles/performance.html) · [API reference](https://open-net-libraries.github.io/Open.Database.Extensions/api/index.html) · [Source and issues](https://github.com/Open-NET-Libraries/Open.Database.Extensions) · MIT license
2 changes: 1 addition & 1 deletion Source/MSSqlClient/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,6 @@ To read rows and outputs from one call, capture them with `CaptureOutput(out DbC
| [Open.Database.Extensions.Channel](https://www.nuget.org/packages/Open.Database.Extensions.Channel/) | Rows into `System.Threading.Channels`. | netstandard2.0, netstandard2.1, net10.0, net11.0 |
| [Open.Database.Extensions.Dataflow](https://www.nuget.org/packages/Open.Database.Extensions.Dataflow/) | Rows into TPL Dataflow blocks. | netstandard2.0, netstandard2.1, net10.0, net11.0 |

Each of the other packages brings Core with it. .NET 8 and .NET 9 use the netstandard2.1 build.
Each of the other packages brings Core with it. .NET 8 and .NET 9 use the netstandard2.1 build; MSSqlClient needs .NET 10 or later on modern .NET.

[Documentation](https://open-net-libraries.github.io/Open.Database.Extensions/) · [API reference](https://open-net-libraries.github.io/Open.Database.Extensions/api/index.html) · [Source and issues](https://github.com/Open-NET-Libraries/Open.Database.Extensions) · MIT license
3 changes: 2 additions & 1 deletion docsite/CONTRIBUTING-DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ Every push to `master` rebuilds and publishes the site (`.github/workflows/docs.
- **Package heroes:** the banner directly under the H1 of each package README is `docsite/images/hero-<package>.svg` (1280 by 200; Core is 260). Left column: the ODX mark (a database and the letters ODX, in the package's accent color) with the package name; then the tagline; then a small scene. ODX is the acronym and the mark, not the name. The site name (`_appName` and `_appTitle` in `docfx.json`) and the H1 of the root `README.md` say "Open.Database.Extensions (ODX)"; the landing page `docsite/index.md` has no H1, by design (the header shows the name and the banner says what the library is, with its alt text as the accessible name; its front matter `title` is the browser-tab title); the package README H1s and all prose keep the full name Open.Database.Extensions. The banner's alt text carries the tagline; never repeat the tagline as text next to a banner. Each is linked by its absolute `raw.githubusercontent.com` URL because nuget.org shows only images from allow-listed hosts (that host is one). Each paints its own soft background in a light and a dark palette (`prefers-color-scheme`), because nuget.org's page theme can differ from the operating system's; keep the contrast soft and any motion subtle (`prefers-reduced-motion` turns it off).
- **Build locally:** `dotnet tool restore`, then `dotnet docfx docsite/docfx.json --serve`.
- **Links:** `docsite/tools/check-links.ps1` checks the built site and the six README files (the root one and the five package ones): every page, file and anchor must resolve, a README link must be absolute, a link into this repository's `master` branch (or the ref a pull request builds from, which DocFX uses for its "View source" links) is checked against the checkout, and an external link fails the run only on a hard 404 or 410 (a timeout or a refusal is listed, not failed). Run it after the local build: `pwsh docsite/tools/check-links.ps1` (add `-SkipExternal` to skip the network).
- **Failures:** warnings are listed in the workflow summary and never block a deploy. A DocFX error, a sample that does not compile or a broken link does, and the live site stays as it was.
- **Package README rules:** `docsite/tools/check-readmes.ps1` checks the five package READMEs: the banner is directly under the H1 and its tagline is not repeated as text, every image is on a host nuget.org renders, there is no raw HTML block tag, and the "The packages" section is identical in all five. Run it with `pwsh docsite/tools/check-readmes.ps1`.
- **Failures:** warnings are listed in the workflow summary and never block a deploy. A DocFX error, a sample that does not compile, a broken link or a package README that breaks its rules does, and the live site stays as it was.
5 changes: 0 additions & 5 deletions docsite/api/overview/Open.Database.Extensions.Core.md

This file was deleted.

11 changes: 5 additions & 6 deletions docsite/articles/async-buffers.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The query is read with the same read as every other terminal: `Read()` by defaul

<div style="overflow-x: auto; margin: 1rem 0;"><img src="../images/async-buffers-reader-open.svg" alt="Three panels of paired bars: reader-open time in milliseconds for 10,000 rows. Consumer at 40 ns per row: chunk stream 6.19, no buffer 6.39. At 1 microsecond per row: 6.26 against 16.01. Waiting 20 microseconds per 100 rows: 6.17 against 8.01." style="display: block; width: 100%; min-width: 600px; height: auto;"></div>

Three panels, each a pair of bars that start at zero, on one scale: how long the reader is held open for a result of 10,000 rows, as the consumer gets slower. The left bar of each pair is `ToPooledBufferStream`; the right bar is no buffer, the consumer working inside the read. At 40 ns per row the pair is 6.19 and 6.39 ms. At 1 µs per row it is 6.26 and 16.01 ms. With a 20 µs wait per 100 rows it is 6.17 and 8.01 ms. The chunk stream holds the reader the same time however slow the consumer is; without a buffer the reader is held as long as the consumer takes. The source is [pooled-buffer-cost.csv](../perf-data/pooled-buffer-cost.csv) (run pbcost-A, build `6a770e8`, 2026-11-23): a synthetic provider on net11 with a 50 µs refill every 100 rows, one run. It is not a real database.
Three panels, each a pair of bars that start at zero, on one scale: how long the reader is held open for a result of 10,000 rows, as the consumer gets slower. The left bar of each pair is `ToPooledBufferStream`; the right bar is no buffer, the consumer working inside the read. The chunk stream holds the reader the same time however slow the consumer is; without a buffer the reader is held as long as the consumer takes. The source is [pooled-buffer-cost.csv](../perf-data/pooled-buffer-cost.csv) (run pbcost-A, build `6a770e8`, 2026-11-23): a synthetic provider on net11 with a 50 µs refill every 100 rows, one run. It is not a real database.

## The three terminals

Expand Down Expand Up @@ -198,7 +198,7 @@ The measurements behind these choices (which pool, how rows are cleared, and whe

A pooled array that goes back with rows in it keeps them reachable while it sits in the pool, and any other code in the process can rent the same array next. So ODX decides, for every array it rents, with one rule:

1. **Rows that hold references are always cleared.** A class, a string, a struct that contains either: the used rows are cleared before the array goes back, so a pooled array never keeps a row alive. Nothing turns this off.
1. **Rows that hold references are always cleared.** A class, a string, a struct that contains either: the used rows are cleared before the array goes back, so a pooled array never keeps a row alive. Nothing turns this off. On `netstandard2.0` every row type counts as holding references, so there every array is cleared and neither the switch nor `clearOnReturn: false` turns it off.
2. **Rows with no references depend on the terminal.** An `int` or a plain struct holds nothing to keep alive, so clearing them costs time for no gain unless the values are sensitive. A collecting terminal (`ToList`, `ToArray`, `ToImmutableArray`, `ToHashSet`, the dictionaries, on a view or on a reader) copies its rows out and never shows its arrays, so it hides its pooling: with no pool offered it **always clears**, whatever the switch says, and with `UsePool(pool, clearOnReturn)` it follows `clearOnReturn`. A buffer or a stream hands its arrays to you, so it does not clear them unless asked, as follows.

Two settings raise that default for the buffers and streams, and the more specific one wins.
Expand All @@ -217,7 +217,7 @@ Or in code, before the first query: `AppContext.SetSwitch("Open.Database.Extensi

[!code-csharp[](../samples/AsyncBuffers.cs#buffers_clearing_shared)]

An explicit `clearOnReturn: true` clears value rows whatever the switch says. An explicit `clearOnReturn: false` keeps them as they are, also when the switch is on: this is the opt-out, and it is per query, for the collecting terminals as well as for the buffers and streams. It cannot lower the floor: `clear` controls rows with no references, and rows that hold references are always cleared. The switch has no part in a collecting terminal: with no `UsePool` it clears anyway.
An explicit `clearOnReturn: true` clears value rows whatever the switch says. An explicit `clearOnReturn: false` keeps them as they are, also when the switch is on: this is the opt-out, and it is per query, for the collecting terminals as well as for the buffers and streams. It cannot lower the floor: `clearOnReturn` controls rows with no references, and rows that hold references are always cleared. The switch has no part in a collecting terminal: with no `UsePool` it clears anyway.

### Your own pool

Expand Down Expand Up @@ -265,19 +265,18 @@ Chunks start at 16 rows and double: 16, 32, 64 and so on. A buffer keeps doublin

The numbers come from a synthetic provider on net11, not from a real database, and they are one run each. The figure and the simulated-link numbers were measured with `AsyncReads()` on for every variant, so the refill waits are real awaits; with the default `Read()` the buffer and `ToArrayAsync` held the reader 5.44 and 5.32 ms at a 50 µs refill. The refill timer busy-waits on one of the four physical cores (eight logical processors) the run used, so the overlap ran on about three cores. Data: [pooled-buffer-cost.csv](../perf-data/pooled-buffer-cost.csv) ([source and conditions](../perf-data/pooled-buffer-cost.source.txt)).

- Reader-open time stays flat as the consumer slows. For the chunk stream at 10,000 rows it is 6.19, 6.26 and 6.17 ms for the three consumers in the figure above.
- On a simulated link the buffer holds the reader about as long as `ToArrayAsync`. At a 50 µs refill every 100 rows the buffer held it 6.26 ms and `ToArrayAsync` 6.41 ms (the buffer 2.2% less, inside the 0.29 ms error of the `ToArrayAsync` total); with the default `Read()` it was 5.44 and 5.32 ms (the buffer 2.2% more).
- At zero latency and 10,000 rows, dumping a result into a buffer held the reader 403.3 µs against 390.0 µs for `ToArrayAsync`, 3.4% longer. The whole call took 434.2 against 391.2 µs, 11.0% longer; the buffer's total includes its dispose, which clears the references of the rows, and the reader-open time does not. The buffer pays that to be able to hand the rows to someone else.

## When to use something else

When the rows are only read or written once, the buffer is the default, whatever the size: the rows exist once and no list is built. It is not faster: see [What it costs](#what-it-costs).
When the rows are only read or written once, the buffer is the recommended way: the rows exist once and no list is built. It is not faster: see [What it costs](#what-it-costs).

To keep or change the rows, use `ToArrayAsync` or `ToListAsync`: the copy is yours and there is nothing to dispose.

[!code-csharp[](../samples/AsyncBuffers.cs#buffers_rows_to_keep)]

To read a query while a consumer works, use the pooled streams: the connection is released as soon as the last row is read. See [Channels and Dataflow](channels-and-dataflow.md).
Use a stream only when a buffer does not fit: stopping early (the first rows, or until one row is found; a `break` cancels the read), or feeding a pipeline ([Channels and Dataflow](channels-and-dataflow.md)). The pooled streams read ahead and release the connection as soon as the last row is read, so the rows a slow consumer has not taken wait in memory. `Stream` holds the connection while your loop works on each row, and `StreamBuffered` holds it once its buffer is full: both take a stall timeout and are the last resort (see [Terminals](mapping.md#terminals)).

## Sources

Expand Down
Loading