From 6c47ac90d7a1e2a8ec3da7b17bfbb8fd4094ed86 Mon Sep 17 00:00:00 2001 From: electricessence <5899455+electricessence@users.noreply.github.com> Date: Sat, 5 Dec 2026 19:49:16 -0800 Subject: [PATCH 1/6] Docs pass for 11.0.x: false statements fixed, the samples in a blog domain, release notes tidy, README rules checked in CI Six reviewers (page groups against the 11.0.x code, arbitrated) found these statements false or stale; each is fixed: - mapping: ImmutableArray has no second copy on .NET 10 and later (the netstandard builds that .NET 8 and 9 take copy it once); DateOnly and TimeOnly are handled on .NET 10 and later only; Map() reads through a generated reader, the runtime map is the one built from expression trees; the library has no attribute that renames a column (it has the null attributes); a bad value's exception names no member or column, the others do; the OrDefault forms give default for a value type. - async buffers: on netstandard2.0 every array is cleared; the parameter is clearOnReturn, not clear. async reads: the connection opens before the command executes (the text and the figure said the reverse); "UNMEASURED" in capitals removed. - expressive commands: ExpressiveCommand has async terminals, what the last two types add is ReadAsync, ExecuteNonQueryAsync and ExecuteScalarAsync; a byte-count claim no data file backs is removed; `default` throws InvalidOperationException; one example uses the sync Execute, now ExecuteAsync; shaping rows: a factory can return null (the row stays), more than 16 parameters need a declared delegate type. - Dapper page: output parameters are read on the chain (ExecuteOutputAsync, Output, CaptureOutput); how-little-code: Items is awaited; performance: no comparison with an older build in a current-version page. - getting started: MSSqlClient needs .NET 10 or later on modern .NET (not .NET 8 or 9); the five READMEs say so; the index no longer says every sample is compiled (a few snippets are text). - Benchmarks pages: the providers list, one run per case with its exception, the data-file list, ToChannelReader(singleReader: true). The samples that used orders, customers and stock now use a blog domain (Draft, PostCounts); the samples build with 0 warnings and run 267 of 267 checks. Release notes: the 11.0.0 section has no release-candidate heading; the changes made after rc.18 are the first part of the release-candidates section, which says who needs it. docsite/tools/check-readmes.ps1, run by docs.yml, checks the five package READMEs: the banner under the H1 with its tagline not repeated, image hosts on nuget.org's list, no raw HTML block, and one identical "The packages" section. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/docs.yml | 3 + Source/Channel/README.md | 2 +- Source/Core/README.md | 2 +- Source/Dataflow/README.md | 2 +- Source/Extensions/README.md | 2 +- Source/MSSqlClient/README.md | 2 +- docsite/CONTRIBUTING-DOCS.md | 3 +- docsite/articles/async-buffers.md | 4 +- docsite/articles/async-reads.md | 16 ++-- docsite/articles/benchmarks/how-we-measure.md | 6 +- docsite/articles/benchmarks/map-cost.md | 2 +- docsite/articles/benchmarks/pipelines.md | 4 +- docsite/articles/channels-and-dataflow.md | 2 +- docsite/articles/coming-from-dapper.md | 4 +- docsite/articles/expressive-commands.md | 18 ++-- docsite/articles/getting-started.md | 2 +- docsite/articles/how-little-code.md | 4 +- docsite/articles/mapping.md | 24 ++--- docsite/articles/performance.md | 4 +- docsite/articles/release-notes.md | 12 ++- docsite/articles/shaping-rows.md | 4 +- docsite/articles/whats-new-11.md | 2 +- docsite/images/asyncreads-flow.svg | 10 +- docsite/index.md | 2 +- docsite/samples/Db.cs | 6 +- docsite/samples/Mapping.cs | 64 ++++++------- docsite/samples/Models.cs | 24 ++--- docsite/samples/Program.cs | 10 +- docsite/tools/check-readmes.ps1 | 95 +++++++++++++++++++ 29 files changed, 218 insertions(+), 117 deletions(-) create mode 100644 docsite/tools/check-readmes.ps1 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 1764656a..f9267104 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -66,6 +66,9 @@ jobs: - 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 + - name: Check the package READMEs (banner, image hosts, one identical packages table) + run: ./docsite/tools/check-readmes.ps1 + - name: Summarize warnings if: always() continue-on-error: true diff --git a/Source/Channel/README.md b/Source/Channel/README.md index dd4736bc..b2dae32d 100644 --- a/Source/Channel/README.md +++ b/Source/Channel/README.md @@ -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 diff --git a/Source/Core/README.md b/Source/Core/README.md index 0e11f8d4..f7d37e35 100644 --- a/Source/Core/README.md +++ b/Source/Core/README.md @@ -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). diff --git a/Source/Dataflow/README.md b/Source/Dataflow/README.md index 3cda2708..8c452b25 100644 --- a/Source/Dataflow/README.md +++ b/Source/Dataflow/README.md @@ -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 diff --git a/Source/Extensions/README.md b/Source/Extensions/README.md index aebd8ac1..57c063db 100644 --- a/Source/Extensions/README.md +++ b/Source/Extensions/README.md @@ -66,6 +66,6 @@ var connectionFactory = new DbConnectionFactory( | [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 diff --git a/Source/MSSqlClient/README.md b/Source/MSSqlClient/README.md index dca23464..4917dbf5 100644 --- a/Source/MSSqlClient/README.md +++ b/Source/MSSqlClient/README.md @@ -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 diff --git a/docsite/CONTRIBUTING-DOCS.md b/docsite/CONTRIBUTING-DOCS.md index dd5e808e..69ad54e7 100644 --- a/docsite/CONTRIBUTING-DOCS.md +++ b/docsite/CONTRIBUTING-DOCS.md @@ -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-.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. \ No newline at end of file +- **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 or a broken link or a package README that breaks its rules does, and the live site stays as it was. diff --git a/docsite/articles/async-buffers.md b/docsite/articles/async-buffers.md index ae6354b5..79a07e6d 100644 --- a/docsite/articles/async-buffers.md +++ b/docsite/articles/async-buffers.md @@ -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. @@ -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 diff --git a/docsite/articles/async-reads.md b/docsite/articles/async-reads.md index c97dbbb3..e09d80f8 100644 --- a/docsite/articles/async-reads.md +++ b/docsite/articles/async-reads.md @@ -1,10 +1,10 @@ # Row reads: sync by default, AsyncReads() to opt in -Every command-level terminal and mapped view reads its rows with `Read()`, and that includes the async terminals. `ToListAsync`, `FirstOrDefaultAsync` and the rest still execute the command, and open the connection, asynchronously; only the row reads are synchronous. `AsyncReads()` opts one call in to reading the rows with `ReadAsync(token)`. +Every command-level terminal and mapped view reads its rows with `Read()`, and that includes the async terminals. `ToListAsync`, `FirstOrDefaultAsync` and the rest still open the connection and execute the command asynchronously; only the row reads are synchronous. `AsyncReads()` opts one call in to reading the rows with `ReadAsync(token)`. ## The default, stated plainly -This covers every terminal on a command (`cmd.Map().ToListAsync(token)`, `FirstOrDefaultAsync`, `ToArrayAsync` and the others), and every mapped view: `Map()` and `Map(Func)`, on an expressive command and on a plain `IDbCommand`. The command still executes, and the connection still opens, asynchronously. Only the rows are read with `Read()`. +This covers every terminal on a command (`cmd.Map().ToListAsync(token)`, `FirstOrDefaultAsync`, `ToArrayAsync` and the others), and every mapped view: `Map()` and `Map(Func)`, on an expressive command and on a plain `IDbCommand`. The connection still opens, and the command still executes, asynchronously. Only the rows are read with `Read()`. `AsyncReads()` opts one call in to `ReadAsync(token)`, with synchronous getters. It changes only the row read: every async terminal reads through the later result sets with `NextResultAsync(token)`, with or without it. @@ -39,7 +39,7 @@ Both return the same rows. The sample cannot show which read was used: SQLite's ## What an async terminal does, and where a thread waits -An async terminal has three stages: it executes the command, it opens the connection, and it reads the rows. The first two are awaited in both lanes of the figure, so the thread is free while they run. The lanes differ at the third. While a row is still on the network, `Read()` holds the thread until the row arrives. `ReadAsync` returns an incomplete task, the thread goes back to the pool, and a continuation resumes when the row arrives. +An async terminal has three stages: it opens the connection, it executes the command, and it reads the rows. The first two are awaited in both lanes of the figure, so the thread is free while they run. The lanes differ at the third. While a row is still on the network, `Read()` holds the thread until the row arrives. `ReadAsync` returns an incomplete task, the thread goes back to the pool, and a continuation resumes when the row arrives.
Two lanes. Default: the thread reads with Read and is blocked while a row is on the wire. Opt in: ReadAsync releases the thread while the row is on the wire.
@@ -59,7 +59,7 @@ The default is the right read for most calls. A few callers cannot spend a threa ### What it does -Rows are read with `ReadAsync(token)` and synchronous getters. The executing, the opening and the read through the later result sets (`NextResultAsync(token)`) are asynchronous with or without it. It changes nothing on a synchronous terminal. +Rows are read with `ReadAsync(token)` and synchronous getters. The opening, the executing and the read through the later result sets (`NextResultAsync(token)`) are asynchronous with or without it. It changes nothing on a synchronous terminal. It is available in these places: @@ -81,7 +81,7 @@ A cancel reaches a buffer or a stream per row with the default read. With `Async Use it when the calling thread must not block on network waits for rows: for example, a slow link with large result sets, where blocked threads are the scarce resource. -That benefit, a thread released while rows are on the wire, is UNMEASURED: no run measured a gain from releasing the thread. +That benefit, a thread released while rows are on the wire, is not measured: no run measured a gain from releasing the thread. ### What it costs @@ -95,13 +95,11 @@ On `Map()`, measured with `SequentialAccess()`, equal memory (219.2 against 2 Measured, synthetic, `Map()` shape: with a read wait every 100 rows (20 µs) and 8 busy thread-pool items, 1,000 rows at width 20 took 2.23 ms with the opt-in against 0.28 ms with the default (8.0 times as long). This is a synthetic provider, one run, one width; do not generalize past that setup. See [Sync reads against async reads](benchmarks/sync-vs-async.md). -On a real link it is UNMEASURED. +On a real link it is not measured. ### The large-value warning -One value of 100 MB (one row, SQL Server, over a simulated slow link) took 8.86 s with a raw sync `Read` and 48.0 s with raw `Default` and `ReadAsync`: 5.4 times as long. `Map()` with `AsyncReads()` and sequential access took 8.86 s, as the raw `SequentialAccess` cell did. Every map reads with the default access mode, so with `AsyncReads()` on a very large value, add [`SequentialAccess()`](expressive-commands.md#sequential-access-for-very-large-values); without it the 48.0 s cell is the one that applies. ODX with `AsyncReads()` and default access on a 100 MB value was NOT measured: its cost is inferred from the raw cell. The chart and the table are on [Slow links and large values](benchmarks/slow-links-and-large-values.md#one-100-mb-value). - -The default, a synchronous `Read`, is the safe choice for large values. +One value of 100 MB (one row, SQL Server, over a simulated slow link) took 8.86 s with a raw sync `Read` and 48.0 s with raw `Default` and `ReadAsync`: 5.4 times as long. `Map()` with `AsyncReads()` and sequential access took 8.86 s, as the raw `SequentialAccess` cell did. Every map reads with the default access mode, so with `AsyncReads()` on a very large value, add [`SequentialAccess()`](expressive-commands.md#sequential-access-for-very-large-values); without it the 48.0 s cell is the one that applies. ODX with `AsyncReads()` and default access on a 100 MB value was not measured: its cost is inferred from the raw cell. The chart and the table are on [Slow links and large values](benchmarks/slow-links-and-large-values.md#one-100-mb-value). ## Sources diff --git a/docsite/articles/benchmarks/how-we-measure.md b/docsite/articles/benchmarks/how-we-measure.md index f25aaea1..d8098812 100644 --- a/docsite/articles/benchmarks/how-we-measure.md +++ b/docsite/articles/benchmarks/how-we-measure.md @@ -6,7 +6,7 @@ Every page in [Benchmarks](../performance.md) is measured the same way. This pag - Almost every number comes from [BenchmarkDotNet](https://benchmarkdotnet.org/) 0.15.8, run in Release mode on one desktop PC, with every case run once. The exceptions are [Slow links and large values](slow-links-and-large-values.md), which uses the project's own probe programs against SQL Server in a container, and the bin tests on [Pooling and clearing](pooling-and-clearing.md); those pages say so. - All the rows of a result come back as the same objects from every library. A check in the benchmark project (`--verify`) fails if two variants return different data. -- Most runs use a synthetic reader, so they show the library's own cost with no database in the way. Two runs use a real database (SQL Server LocalDB and a SQLite file), and they show how much of that cost survives. +- Most runs use a synthetic reader, so they show the library's own cost with no database in the way. The runs on a real database (SQL Server LocalDB and a SQLite file, one run on SQL Server in a container, the end-to-end pooling runs on SQLite in memory) show how much of that cost survives. - Gaps of a few percent between two bars are noise. We say so on each page where it applies. ## What the three numbers mean @@ -45,7 +45,7 @@ The synthetic reader can also add a wait every N rows (a buffer refill) and keep ## How sure are the numbers? -Each case is one BenchmarkDotNet run. On the real providers BenchmarkDotNet reported error margins (the half-width of its 99.9% confidence interval) of 0.3 to 6.3% of the mean, and the tables show each one, so a gap of a few percent between two bars is not a result. Allocation does not have this problem: it is the same every time. +Each case is one BenchmarkDotNet run, except that [ODX against Dapper](library-comparison.md) ran each real provider twice. On the real providers BenchmarkDotNet reported error margins (the half-width of its 99.9% confidence interval) of 0.3 to 6.3% of the mean, and the tables show each one, so a gap of a few percent between two bars is not a result. Allocation does not have this problem: it is the same every time. ## How fresh is the data? @@ -53,7 +53,7 @@ Each data set has a CSV file in the repository and a source file beside it that [!include[](../../includes/perf/freshness.md)] -Data files and sources: [library-synthetic](../../perf-data/library-synthetic.csv) ([source](../../perf-data/library-synthetic.source.txt)), [library-real](../../perf-data/library-real.csv) ([source](../../perf-data/library-real.source.txt)), [synthetic-overhead](../../perf-data/synthetic-overhead.csv) ([source](../../perf-data/synthetic-overhead.source.txt)), [width-sweep](../../perf-data/width-sweep.csv) ([source](../../perf-data/width-sweep.source.txt)), [map-cost](../../perf-data/map-cost.csv) ([source](../../perf-data/map-cost.source.txt)), [real-providers](../../perf-data/real-providers.csv) ([source](../../perf-data/real-providers.source.txt)), [sync-async](../../perf-data/sync-async.csv) ([source](../../perf-data/sync-async.source.txt)). +Every data file and its source file: [Performance data](../performance-data.md). Each page gives the build and date of its runs on its *Build, date, machine* line, and says so at the top when it rests on older or hand-recorded numbers. diff --git a/docsite/articles/benchmarks/map-cost.md b/docsite/articles/benchmarks/map-cost.md index 0ded426f..7f3267b6 100644 --- a/docsite/articles/benchmarks/map-cost.md +++ b/docsite/articles/benchmarks/map-cost.md @@ -26,7 +26,7 @@ You get this by default: a plain `Map()` finds its cached mapping by the resu ## When the mapping is built on every call (older run) -The call-site forms (a collection expression or `new RowMap([...])` written inline) build a new mapping on every call. This older run measured it on a 12-property model, a one-row read, an in-memory provider, at commit `9840925`, .NET 10 and BenchmarkDotNet 0.15.8. It was not repeated on the final code and has no data file. The source is [`RESULTS.md`](https://github.com/Open-NET-Libraries/Open.Database.Extensions/blob/master/Benchmarks/RESULTS.md#rowmapt-a-prebuilt-column-mapping-when-every-column-is-named-differently). +The call-site forms (a collection expression or `new RowMap([...])` written inline) build a new mapping on every call. This older run measured it on a 12-property model, a one-row read, an in-memory provider, at commit `9840925`, .NET 10 and BenchmarkDotNet 0.15.8. It was not repeated on 11.0.x and has no data file. The source is [`RESULTS.md`](https://github.com/Open-NET-Libraries/Open.Database.Extensions/blob/master/Benchmarks/RESULTS.md#rowmapt-a-prebuilt-column-mapping-when-every-column-is-named-differently). | One-row `List` read | Time | Memory | |---|---:|---:| diff --git a/docsite/articles/benchmarks/pipelines.md b/docsite/articles/benchmarks/pipelines.md index 9dbadd41..bffd0304 100644 --- a/docsite/articles/benchmarks/pipelines.md +++ b/docsite/articles/benchmarks/pipelines.md @@ -14,14 +14,14 @@
Two panels of two bars each, each on its own scale, the time to drain 1,000 rows. Channel: plain loop 275.6 microseconds, ToChannel 87.8. BufferBlock: plain loop 132.0 microseconds, Dataflow 95.4.
-The time to move 1,000 rows into a channel (top panel) and into a `BufferBlock` (bottom panel), with ODX (`ToChannelReader(true)` and `ToTargetBlock`, the bars labelled ToChannel and Dataflow) and with a hand-written loop that does the same job. Shorter is better, and each panel has its own scale. +The time to move 1,000 rows into a channel (top panel) and into a `BufferBlock` (bottom panel), with ODX (`ToChannelReader(singleReader: true)` and `ToTargetBlock`, the bars labelled ToChannel and Dataflow) and with a hand-written loop that does the same job. Shorter is better, and each panel has its own scale. [!include[](../../includes/perf/channels.md)] ## How this was measured - **Question:** how much do `ToChannel` and a `BufferBlock` cost against a hand-written loop over the same rows? -- **Setup:** an in-memory provider; 1, 100 and 1,000 rows. Channel: the loop is a producer task that writes every row into an unbounded channel, and the reader drains it; ODX is `Map().ToChannelReader(true)` drained with `ReadAllAsync`. Dataflow: the loop reads the rows, then sends each into a `BufferBlock`, which is drained; ODX is `Map().ToTargetBlock(block, complete: true)`, drained. Both sides produce the same rows. +- **Setup:** an in-memory provider; 1, 100 and 1,000 rows. Channel: the loop is a producer task that writes every row into an unbounded channel, and the reader drains it; ODX is `Map().ToChannelReader(singleReader: true)` drained with `ReadAllAsync`. Dataflow: the loop reads the rows, then sends each into a `BufferBlock`, which is drained; ODX is `Map().ToTargetBlock(block, complete: true)`, drained. Both sides produce the same rows. - **Settings:** BenchmarkDotNet 0.15.8, `--inprocess`, 5 warm-up and 12 measured iterations, one launch, at below-normal priority under a watchdog, one run at a time. Each time is one run; the CSV has no error column. - **Build, date, machine:** build `6a770e8`, 2026-11-23; AMD Ryzen 9 7900, .NET 11.0.0, Windows 10. - **Data:** [channels.csv](../../perf-data/channels.csv) ([source](../../perf-data/channels.source.txt)), from the BenchmarkDotNet reports. diff --git a/docsite/articles/channels-and-dataflow.md b/docsite/articles/channels-and-dataflow.md index 53c0d673..45e1d54d 100644 --- a/docsite/articles/channels-and-dataflow.md +++ b/docsite/articles/channels-and-dataflow.md @@ -96,4 +96,4 @@ Each row is sent with `SendAsync`, so a bounded block that is full makes the pas ## Honest limits -- They cost more than a plain loop for one row (1.61 times for a channel, 2.56 times for a `BufferBlock`). At 1,000 rows `ToChannelReader(true)` took 0.32 times as long as a hand-written channel loop and `ToTargetBlock` 0.72 times; at 100 rows the channel took 0.45 times and the `BufferBlock` 1.10 times. See [Channels and Dataflow against a plain loop](benchmarks/pipelines.md). +- They cost more than a plain loop for one row (1.61 times for a channel, 2.56 times for a `BufferBlock`). At 1,000 rows `ToChannelReader(singleReader: true)` took 0.32 times as long as a hand-written channel loop and `ToTargetBlock` 0.72 times; at 100 rows the channel took 0.45 times and the `BufferBlock` 1.10 times. See [Channels and Dataflow against a plain loop](benchmarks/pipelines.md). diff --git a/docsite/articles/coming-from-dapper.md b/docsite/articles/coming-from-dapper.md index 8ffaec89..1bc5dd46 100644 --- a/docsite/articles/coming-from-dapper.md +++ b/docsite/articles/coming-from-dapper.md @@ -267,9 +267,9 @@ Dapper has features this library does not offer: - **Type handlers and custom type maps.** `SqlMapper.AddTypeHandler` and `SqlMapper.SetTypeMap`. - **Dynamic results.** `Query(sql)` without a type returns dynamic rows. - **Batch execution.** `Execute(sql, IEnumerable)` runs one command once for every item. The extensions have no equivalent: loop over the items and run the command for each, inside one `ExecuteTransactionAsync` (see [A transaction](#a-transaction)). -- **Parameter bags and output parameters.** An anonymous object, `new { id = 1 }`, becomes `AddParams(new { id = 1 })` (see [Name a parameter from its argument](expressive-commands.md#name-a-parameter-from-its-argument)). `DynamicParameters` has no equivalent: add each value with `AddParam`. Output parameters are not part of the chain: to set a direction, use `ExecuteAsync(command => ...)` with the raw `AddParameter` and `AddReturnParameter` extensions on the command. The return value is readable: `ExecuteReturnAsync()` (see [Return values and output parameters](expressive-commands.md#return-values-and-output-parameters)). +- **Parameter bags and output parameters.** An anonymous object, `new { id = 1 }`, becomes `AddParams(new { id = 1 })` (see [Name a parameter from its argument](expressive-commands.md#name-a-parameter-from-its-argument)). `DynamicParameters` has no equivalent: add each value with `AddParam`. Output parameters are read on the chain: `ExecuteOutputAsync()` on a command, `Output()` on a definition, and `CaptureOutput` beside rows; the return value with `ExecuteReturnAsync()` (see [Return values and output parameters](expressive-commands.md#return-values-and-output-parameters) and [Output parameters](expressive-commands.md#output-parameters)). -With the extensions, use `Map(selector)` or `ExecuteReader(reader => ...)` for those jobs. For dynamic rows, `AsObjectArrays()` gives each row as an `object?[]` (`AsDictionaryRows()` as a dictionary): see [Rows without a model](mapping.md#rows-without-a-model). +With the extensions, use `Map(selector)` or `ExecuteReaderAsync(reader => ...)` for those jobs. For dynamic rows, `AsObjectArrays()` gives each row as an `object?[]` (`AsDictionaryRows()` as a dictionary): see [Rows without a model](mapping.md#rows-without-a-model). ## Which method becomes which terminal diff --git a/docsite/articles/expressive-commands.md b/docsite/articles/expressive-commands.md index 3a1f44ed..bb56afe8 100644 --- a/docsite/articles/expressive-commands.md +++ b/docsite/articles/expressive-commands.md @@ -64,11 +64,11 @@ What the definition fixes is what never changes from one call to the next: the c [!code-csharp[](../samples/MapFirst.cs#mapfirst_paged)] -A parameter added after `Using` is added to a query that `Using` made from a definition. A query built the other way (`connection.Command(sql).Map()`) takes its parameters on the command, before `Map`: the mapped view has no `AddParam`. A `default` value of one of these types throws the same exception, as the other structs do. +A parameter added after `Using` is added to a query that `Using` made from a definition. A query built the other way (`connection.Command(sql).Map()`) takes its parameters on the command, before `Map`: the mapped view has no `AddParam`. A `default` value of one of these types throws `InvalidOperationException` when it is used. Everything after `Using` is what a command does: `Map()` is the same extension, every terminal and `SingleResult()` apply, the connection is opened late and closed again only if the call opened it, a factory's connection is disposed and a pool's is given back. `SetTimeout(seconds)` on a definition returns a new definition. A `DbQuery` takes the same sources as `Using` does for a command, but only the typed ones: a connection (`DbConnection`), a transaction, an `IDbConnectionPool` or an `IDbConnectionFactory`; a bare `Func` is not one (wrap it in `new DbConnectionFactory(func)`). -A call allocates less than the command builder and within 7 bytes of ADO.NET written by hand (within 23 bytes at a single value). Names are resolved as a command resolves them (see [Name a parameter from its argument](#name-a-parameter-from-its-argument)): `AddParam(authorId)` finds `@author_id`, and the typed form matches each member of the values type the same way and, when the names are known, does not send a member the query does not declare. A text definition finds its `@name` markers once, when it is made; a procedure's names are kept per server and database when its name has a schema, else per connection source (the factory, the pool or the connection, also for a transaction); see [Parameter names are read once](#parameter-names-are-read-once). +Names are resolved as a command resolves them (see [Name a parameter from its argument](#name-a-parameter-from-its-argument)): `AddParam(authorId)` finds `@author_id`, and the typed form matches each member of the values type the same way and, when the names are known, does not send a member the query does not declare. A text definition finds its `@name` markers once, when it is made; a procedure's names are kept per server and database when its name has a schema, else per connection source (the factory, the pool or the connection, also for a transaction); see [Parameter names are read once](#parameter-names-are-read-once). ### Writes and scalars @@ -115,7 +115,7 @@ A command is not safe to share across threads: one built from a single connectio | `DbConnection`, `DbTransaction`, `IDbConnectionFactory` | `ExpressiveDbCommand` | `DbDataReader` (async reads) | | `SqlConnection` or a `SqlConnectionFactory` (MSSqlClient package) | `ExpressiveSqlCommand` | `SqlDataReader` | -Choose by what you need: only the last two rows have `Async` terminals, so a service that awaits starts from a `DbConnection` or an `IDbConnectionFactory` (for example `IDbConnectionFactory`). Pass a `CommandType` as the second argument of `Command` if you need `TableDirect`. +Choose by what you need: only the last two rows read with `ReadAsync` and have `ExecuteNonQueryAsync` and `ExecuteScalarAsync`, so a service that awaits starts from a `DbConnection` or an `IDbConnectionFactory` (for example `IDbConnectionFactory`). Pass a `CommandType` as the second argument of `Command` if you need `TableDirect`. ## Parameters @@ -129,7 +129,7 @@ A name you write is sent exactly as written: the library never adds or removes a ### Name a parameter from its argument -`AddParam(value)` takes the name from the argument, so you do not spell it twice. The argument must be a variable or a chain of members (properties and fields, members of members): `author`, `search.Author`, `order.Customer.Id`. A type-qualified static or constant is a chain too: `DateTime.UtcNow` derives the name `UtcNow` and `string.Empty` derives `Empty`, so name such a value yourself unless that is the name you want. Deriving needs C# 10 or newer; an older compiler gets an `ArgumentException` and must pass the name. +`AddParam(value)` takes the name from the argument, so you do not spell it twice. The argument must be a variable or a chain of members (properties and fields, members of members): `author`, `search.Author`, `post.Author.Id`. A type-qualified static or constant is a chain too: `DateTime.UtcNow` derives the name `UtcNow` and `string.Empty` derives `Empty`, so name such a value yourself unless that is the name you want. Deriving needs C# 10 or newer; an older compiler gets an `ArgumentException` and must pass the name. [!code-csharp[](../samples/ExpressiveCommands.cs#param_from_argument)] @@ -137,9 +137,9 @@ For a stored procedure the name is settled when the command runs. The provider r 1. Exactly, else ignoring case, else ignoring case and underscores: `TitleContains` finds `@title_contains`. 2. Else with one common parameter prefix dropped from the real name (`p_`, `in_`, `i_`, `prm_`, `par_`, `v_`, or a lone `p` before a capital letter): `Author` finds `@p_author` and `@pAuthor`. A field prefix on the argument (`m_author`, `s_author`) is also tried without it. -3. A chain tries its longer endings first, each through all of those steps before the next: `order.Customer.Id` tries `orderCustomerId`, `CustomerId`, then `Id`, so `@customer_id` and `@p_customer_id` are chosen over a bare `@id`. +3. A chain tries its longer endings first, each through all of those steps before the next: `post.Author.Id` tries `postAuthorId`, `AuthorId`, then `Id`, so `@author_id` and `@p_author_id` are chosen over a bare `@id`. -For example `AddParam(search.Author)` sends `@p_author` when the procedure declares that, `@Author` or `@author` when it declares one of those, and throws when it declares none of them. The prefix step (rule 2) can bind a parameter whose name only starts like a prefix: `Stock` finds `@in_stock`, `Value` finds `@par_value` and `Progress` finds `@in_progress`. When that is not the parameter you mean, name it yourself: `AddParam("stock", stock)`. +For example `AddParam(search.Author)` sends `@p_author` when the procedure declares that, `@Author` or `@author` when it declares one of those, and throws when it declares none of them. The prefix step (rule 2) can bind a parameter whose name only starts like a prefix: `Views` finds `@in_views`, `Value` finds `@par_value` and `Progress` finds `@in_progress`. When that is not the parameter you mean, name it yourself: `AddParam("views", views)`. When the real names are not available, as with a text command or another provider, the last member is used as written, without an `@`: `Author`. The names are read once and then kept: see [Parameter names are read once](#parameter-names-are-read-once). @@ -171,7 +171,7 @@ One change causes no failure and is therefore not noticed: a new parameter that When the database reports no names (the login cannot see the procedure, it declares no parameters, the name has a database part, or the provider cannot report names), that answer is kept with the object your connections come from, never shared, and each argument is sent under the name as written. -Names read inside a transaction are kept even if the transaction rolls back. Give the procedure its schema (`dbo.get_author`): a name without one is resolved by each login's default schema, so it is kept for each source of connections and never shared. +Names read inside a transaction are kept even if the transaction rolls back. Give the procedure its schema (`dbo.get_author`): a name without one is resolved by each login's default schema, so it is never shared. What sharing means for names kept for the whole process: @@ -183,7 +183,7 @@ What sharing means for names kept for the whole process: #### What was sent? -`command.Params` always lists what you added: a name you wrote as written, an argument-derived name as its last member, and the members of an `AddParams` object under their member names. A run never changes it. The real names are worked out in every run, for the connection that run uses, so one command object can run against two databases that name the parameters of a procedure differently. To see what the run sent, give `Execute(command => ...)` a function that reads the provider's command: its `CommandText`, `CommandType` and `Parameters` (name and value of each) already have the real names. The library keeps no log of the statement and has no other hook. +`command.Params` always lists what you added: a name you wrote as written, an argument-derived name as its last member, and the members of an `AddParams` object under their member names. A run never changes it. The real names are worked out in every run, for the connection that run uses, so one command object can run against two databases that name the parameters of a procedure differently. To see what the run sent, give `ExecuteAsync(command => ...)` a function that reads the provider's command: its `CommandText`, `CommandType` and `Parameters` (name and value of each) already have the real names. The library keeps no log of the statement and has no other hook. A derived name stays as written when no real names were read: a text command, another provider, a procedure name with a database part (`otherdb.dbo.proc`), a procedure the login cannot see or that does not exist, or one that declares no parameters. Name the parameters yourself when you call a procedure in another database. @@ -336,7 +336,7 @@ The library reads with the default access mode, in which SqlClient reads a whole - On a command, it applies to every reader the command opens: a reader callback, the `Map` terminals and `LoadTable`. - It is also on every mapped view and definition: `command.Map().SequentialAccess()`. - A selector given to `Map` must read the columns in ascending order, or the provider throws. `Map()`, `AsObjectArrays()` and `AsDictionaryRows()` read in column order, so they work with it. -- With [`AsyncReads()`](async-reads.md) and a very large value, opt in: without it, SqlClient read one 100 MB value [far more slowly](benchmarks/slow-links-and-large-values.md#one-100-mb-value) with `ReadAsync`. +- With [`AsyncReads()`](async-reads.md) and a very large value, add `SequentialAccess()`: without it, SqlClient read one 100 MB value [far more slowly](benchmarks/slow-links-and-large-values.md#one-100-mb-value) with `ReadAsync`. ### Which scalar form diff --git a/docsite/articles/getting-started.md b/docsite/articles/getting-started.md index f4418d3e..fe6e99b8 100644 --- a/docsite/articles/getting-started.md +++ b/docsite/articles/getting-started.md @@ -12,7 +12,7 @@ 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). To use it, add the Core package, which the other packages build on: +.NET 8 and .NET 9 applications use the `netstandard2.1` build; .NET Framework applications use `netstandard2.0` (or `net472` for the SQL Server package, which needs .NET 10 or later on modern .NET: a .NET 8 or .NET 9 application cannot use it). To use it, add the Core package, which the other packages build on: ```sh dotnet add package Open.Database.Extensions.Core diff --git a/docsite/articles/how-little-code.md b/docsite/articles/how-little-code.md index 15995415..c71cf9a0 100644 --- a/docsite/articles/how-little-code.md +++ b/docsite/articles/how-little-code.md @@ -8,7 +8,7 @@ The ODX snippets build each command where it is used, which is how a call is cou ## How the lines are counted -Each cell counts the lines of one method as it would appear in a data-access class: the signature through the closing brace, without blank lines and without comments. `using` directives are not counted. The numbers below are the output of `docsite/tools/count-region-lines.ps1`. The code is written vertically, one argument and one call per line, the same way for all four libraries. +Each cell counts the lines of one method as it would appear in a data-access class: the signature through the closing brace, without blank lines and without comments. `using` directives are not counted. The numbers below are the output of `docsite/tools/count-region-lines.ps1`. The code is written vertically, one call per line, the same way for all four libraries. | Task | Open.Database.Extensions | Dapper | EF Core | plain ADO.NET | |---|---:|---:|---:|---:| @@ -89,7 +89,7 @@ Read one author's rows (the filter is in the SQL again), then build the headline [!code-csharp[](../samples/HowLittleCode.cs#little_buffer_odx)] -`ToPooledBuffer` reads into pooled arrays and `Items` is a read-only list over them. Disposing the view disposes the buffer and returns the arrays to the pool. See [Lifetime and ownership](async-buffers.md#lifetime-and-ownership). +`ToPooledBuffer` reads into pooled arrays; awaiting `Items` gives a read-only list over them. Disposing that view disposes the buffer and returns the arrays to the pool. See [Lifetime and ownership](async-buffers.md#lifetime-and-ownership). **Dapper** diff --git a/docsite/articles/mapping.md b/docsite/articles/mapping.md index 506c907a..6575c3b3 100644 --- a/docsite/articles/mapping.md +++ b/docsite/articles/mapping.md @@ -22,7 +22,7 @@ For the shapes this table does not cover, such as a NULL that means an empty str - **What is set.** The parameters of the constructor, when the type is built through one, and the public instance properties that have a public setter (a record's `init` property included). A parameter and a property of the same name, ignoring case, are one member: it is fed once, through the constructor. Public fields and static properties are not mapped. - **Matching.** A column is matched to the property or constructor parameter with the same name: exactly, else ignoring case, else ignoring case with the underscores dropped from both (see [snake_case columns map to PascalCase properties](#snake_case-columns-map-to-pascalcase-properties)). A column with no matching member is ignored. A property with no matching column keeps the value its constructor gave it. A parameter with no matching column gets its declared default value, else its default (`0`, `null`). A `NULL` cell follows [the NULL rules](#null-in-a-non-nullable-column). - **Columns named differently.** Declare a `RowMap` once that names the column for a property, or ignores a property (see [Columns named differently](#columns-named-differently)). -- **No other conventions.** The library has no mapping attributes of its own. If a column name differs from the property name by more than case and underscores, declare a `RowMap`. +- **No other conventions.** The library has no attribute of its own that renames a column. If a column name differs from the property name by more than case and underscores, declare a `RowMap`. ## Records and constructors @@ -130,7 +130,7 @@ On a command, `Map()` reads the first column of each row as one value, and The rules: -- **Which types.** A primitive, an enum, `string`, `decimal`, `DateTime`, `DateTimeOffset`, `TimeSpan`, `DateOnly`, `TimeOnly`, `Guid`, `byte[]` and a `Nullable<>` of those. Not `object`, `char[]`, a provider type such as `SqlInt32`, or a `Stream` (the reader is closed when the terminal returns): use `Map(selector)` for those. +- **Which types.** A primitive, an enum, `string`, `decimal`, `DateTime`, `DateTimeOffset`, `TimeSpan`, `DateOnly`, `TimeOnly`, `Guid`, `byte[]` and a `Nullable<>` of those (`DateOnly` and `TimeOnly` on .NET 10 and later). Not `object`, `char[]`, a provider type such as `SqlInt32`, or a `Stream` (the reader is closed when the terminal returns): use `Map(selector)` for those. - **The first column, whatever its name.** The other columns are ignored, so select only the one you need. - **Converted like a property of that type.** When the column type matches, or is an integer that fits (a `long` into an `int` is range-checked; a `short` widens), the value is read with the typed getter and nothing is boxed. Otherwise it is converted: a `decimal` into an `int` rounds, text into a `Guid`, an enum from its name (ignoring case) or its number, a `DateTime` into a `DateTimeOffset`. A value that cannot be converted throws `ValueMappingException`. The reader is chosen once per result set, from the type the first row reports. - **NULL.** Follows [the NULL rules](#null-in-a-non-nullable-column): `Map()` over a NULL throws `ValueMappingException` naming `Int32` and the row, and `Map()` gives `null`. @@ -192,7 +192,7 @@ Compilers older than C# 14 have no `field` keyword and need an explicit backing [!code-csharp[](../samples/Mapping.cs#map_call_site)] -The cost is measured: building a map takes 0.19 to 0.87 ms, and a call-site map is built again on every call. See [What building a map costs](benchmarks/map-cost.md). Use these forms only for a one-off, and declare a map for anything that runs more than occasionally. +The cost is measured: building a map takes 0.19 to 0.87 ms, and a call-site map is built again on every call. See [What building a map costs](benchmarks/map-cost.md). The constructor also takes the pairs as arguments, with no brackets: `Map(new RowMap(pair, pair))`. It is the same one-off and costs the same: @@ -278,7 +278,7 @@ The name match is the one thing a generated reader does that a hand-written read ### Output parameters -Output parameters read into a model (`ExecuteOutputAsync()`, see [Output parameters](expressive-commands.md#output-parameters)) follow the rules of this page: each member is matched to a parameter and the model is built as from a row, always by the runtime map. Two things apply only there: a `decimal` member needs `[Column(TypeName = "decimal(p,s)")]` for the precision and scale it is sent with, a `DateTime` member is sent as `DbType.DateTime2`, a `DateOnly` as `DbType.Date` and a `TimeOnly` as `DbType.Time`. +Output parameters read into a model (`ExecuteOutputAsync()`, see [Output parameters](expressive-commands.md#output-parameters)) follow the rules of this page: each member is matched to a parameter and the model is built as from a row, always by the runtime map. Two things apply only there: a `decimal` member needs `[Column(TypeName = "decimal(p,s)")]` for the precision and scale it is sent with, a `DateTime` member is sent as `DbType.DateTime2`, and on .NET 10 and later a `DateOnly` as `DbType.Date` and a `TimeOnly` as `DbType.Time`. ## Types and NULL @@ -286,7 +286,7 @@ This section, and the NULL messages below, describe the runtime map; a [generate - integers convert to other integer types and to enums, range-checked (an overflow throws `ValueMappingException`); - integers and floating-point values widen to `float`, `double` and `decimal`; -- a `DateTime`, a `DateTimeOffset`, a `TimeSpan` or text goes to a `DateOnly`, `TimeOnly`, `DateTimeOffset` or `TimeSpan` property (`DateOnly` and `TimeOnly` on .NET 10): a date column arrives as a `DateTime`, a time column as a `TimeSpan`, and SQLite returns text, which is read with the invariant culture; +- a `DateTime`, a `DateTimeOffset`, a `TimeSpan` or text goes to a `DateOnly`, `TimeOnly`, `DateTimeOffset` or `TimeSpan` property (`DateOnly` and `TimeOnly` on .NET 10 and later): a date column arrives as a `DateTime`, a time column as a `TimeSpan`, and SQLite returns text, which is read with the invariant culture; - anything else goes through a general conversion: a string to an enum (ignoring case) or a `Guid`, a `byte[]` to a `Guid`, any value to `string` except a `byte[]`, which throws, and otherwise `Convert.ChangeType`, so a fractional value rounds (halves to even) into an integer property. ## NULL in a non-nullable column @@ -300,7 +300,7 @@ If the type says `int`, it is an `int`. A NULL into a member the C# type declare | Any provider, a column that is converted (another type, or none, as for SQLite's `null as title`) | none: ODX detects the NULL | The NULL message, with `SqlNullValueException` inside | | A provider whose getter casts | `InvalidCastException` | A message that names both causes: a NULL, or a column type that does not convert | -`Nullable` (`int?`), a reference declared nullable (`string?`, or `[AllowNull]` on a property), a reference type in code with nullable annotations off, and a member declared as a type parameter (`T Value`) get `null`. To accept a NULL, declare the member nullable, give it a [null policy](#null-policy), or give it a [converter](#converting-a-column) whose column type is nullable. +A member that accepts a NULL gets `null`. To accept a NULL, declare the member nullable, give it a [null policy](#null-policy), or give it a [converter](#converting-a-column) whose column type is nullable. [!code-csharp[](../samples/Mapping.cs#map_null_error)] @@ -319,7 +319,7 @@ The rule reads the nullable annotations the compiler stores in the assembly, so | `[NullPolicy(NullAction.Default)]` | The member's initializer, else its default; a constructor parameter's declared default, else its default | | `[NullValue(0)]` (a member only) | The value, converted to the member's type when the map is created | -[!code-csharp[](../samples/Models.cs#order_line_model)] +[!code-csharp[](../samples/Models.cs#post_counts_model)] - **`[NullValue]` wins.** It overrides any policy: the type's, and the member's own. - **A member's policy overrides the type's.** `[NullPolicy(NullAction.None)]` on one member of a `Throw` type takes that member out of the check. @@ -339,7 +339,7 @@ With no attribute the default read is the fast path, and a NULL into a non-nulla ## Values that cannot be mapped -A row that cannot be mapped (an unconvertible value, an overflow, a NULL into a non-nullable member, a constructor that throws) throws `ValueMappingException`, a `DataException` (not an `InvalidOperationException`). Its message names the model and, when the row is known, the 0-based row of the result set (`Unable to map row 0 to 'Post'.`; a mapper called outside the library's own read loop cannot know the row), `TargetType` is the model (the value's type for `Map()`), and the error that stopped the row is its `InnerException`. It names no member or column: the reader reads nothing more once a row fails. To have a NULL named by member and column, give the member `[NullPolicy(NullAction.Throw)]` (see [Null policy](#null-policy)). A `required` property no column feeds throws it too, naming the property and the column, without an inner exception (see [`required` and `init` members](#required-and-init-members)). Provider exceptions (`DbException`) and cancellation pass through unwrapped. +A row that cannot be mapped (an unconvertible value, an overflow, a NULL into a non-nullable member, a constructor that throws) throws `ValueMappingException`, a `DataException` (not an `InvalidOperationException`). Its message names the model and, when the row is known, the 0-based row of the result set (`Unable to map row 0 to 'Post'.`; a mapper called outside the library's own read loop cannot know the row), `TargetType` is the model (the value's type for `Map()`), and the error that stopped the row is its `InnerException`. For a bad value it names no member or column: the reader reads nothing more once a row fails. To have a NULL named by member and column, give the member `[NullPolicy(NullAction.Throw)]` (see [Null policy](#null-policy)). A `required` property no column feeds throws it too, naming the property and the column, without an inner exception (see [`required` and `init` members](#required-and-init-members)). Provider exceptions (`DbException`) and cancellation pass through unwrapped. [!code-csharp[](../samples/Mapping.cs#map_value_error)] @@ -349,7 +349,7 @@ Some columns are not the type the model wants: a number the model keeps as text, `Convert(member, convert)` returns a new `RowMap` (the one you call it on is unchanged), so it chains. `TColumn` is the type the column is read as, which the delegate receives; `TMember` is what it returns: the member's type, or one assignable to it. It uses the column the map already names for the member (a pair), else the column the member matches by name. `Convert(member, column, convert)` also names the column: a pair with a converter. Declare the map once, like any other: -[!code-csharp[](../samples/Models.cs#order_model)] +[!code-csharp[](../samples/Models.cs#draft_model)] [!code-csharp[](../samples/Mapping.cs#map_converted)] @@ -366,7 +366,7 @@ Some columns are not the type the model wants: a number the model keeps as text, ## Terminals -`ToArrayAsync`, `ToListAsync`, `ToImmutableArrayAsync`, `ToDictionaryAsync`, `ToHashSetAsync`, `FirstAsync`, `FirstOrDefaultAsync`, `SingleAsync` and `SingleOrDefaultAsync`. `FirstAsync` and `SingleAsync` throw `InvalidOperationException` when the query returns no row (and `SingleAsync` when it returns more than one); the `OrDefault` forms return `null` for no rows. A row whose value is `NULL` is still a row. Prefer `ToArrayAsync` for results you only read: it allocates one exactly sized array, and an empty result is the shared empty array. Use `ToListAsync` when you add to or remove from the result afterwards. +`ToArrayAsync`, `ToListAsync`, `ToImmutableArrayAsync`, `ToDictionaryAsync`, `ToHashSetAsync`, `FirstAsync`, `FirstOrDefaultAsync`, `SingleAsync` and `SingleOrDefaultAsync`. `FirstAsync` and `SingleAsync` throw `InvalidOperationException` when the query returns no row (and `SingleAsync` when it returns more than one); the `OrDefault` forms return `null` (`default` for a value type such as `int`) for no rows. A row whose value is `NULL` is still a row. Prefer `ToArrayAsync` for results you only read: it allocates one exactly sized array, and an empty result is the shared empty array. Use `ToListAsync` when you add to or remove from the result afterwards. An application declares these queries once and runs them where it needs them, so the queries are declared first, and each call below is shown on them, then written ad hoc, with nothing to declare: @@ -394,7 +394,7 @@ Or, simply expressive, ad hoc: [!code-csharp[](../samples/Mapping.cs#map_dictionary_values)] -For a result that nobody else can change, use `ToImmutableArrayAsync`: it wraps the exactly sized array the read produced, with no second copy on .NET 8 and later (the netstandard2.0 build copies it once). There is no `ToImmutableDictionary` or `ToImmutableHashSet` terminal. For a lookup that cannot change, call `ToFrozenDictionary()` on the result of `ToDictionaryAsync`. +For a result that nobody else can change, use `ToImmutableArrayAsync`: it wraps the exactly sized array the read produced, with no second copy on .NET 10 and later (the netstandard builds copy it once). There is no `ToImmutableDictionary` or `ToImmutableHashSet` terminal. For a lookup that cannot change on .NET 8 and later, call `ToFrozenDictionary()` on the result of `ToDictionaryAsync`. `Skip` and `Take` are part of the query: skipped rows are advanced without being mapped, and reading stops once the take is satisfied. Call `Skip` before `Take`, as the types enforce: @@ -569,7 +569,7 @@ The mapping from a result-set shape (column names and column types) to `T` is co ## Trimming and native AOT -Open.Database.Extensions is not marked trimmable, and native AOT is not supported in 11.0. `Map()` and `AddParams(...)` read your types and the provider's data reader type by reflection, and build row readers as expression trees. Under native AOT, .NET interprets these expression trees instead of compiling them, so every row the runtime map reads is slower. +Open.Database.Extensions is not marked trimmable, and native AOT is not supported in 11.0. The runtime map (see [Generated readers](#generated-readers)) and `AddParams(...)` read your types and the provider's data reader type by reflection, and the runtime map builds row readers as expression trees. Under native AOT, .NET interprets these expression trees instead of compiling them, so every row the runtime map reads is slower. If you publish with `PublishTrimmed=true`, keep what ODX reads: the public constructors, properties and fields of every type you pass to `Map()` and of every object you pass to `AddParams`, and the public methods of the provider's data reader type. A model type that is not kept fails at the first query with a message that starts `'Post' cannot be mapped: it has no public constructor.` A reader type that is not kept fails with `Value cannot be null. (Parameter 'method')`. diff --git a/docsite/articles/performance.md b/docsite/articles/performance.md index 0604a947..437c85c2 100644 --- a/docsite/articles/performance.md +++ b/docsite/articles/performance.md @@ -18,7 +18,7 @@ How long the connection is held open (top) and how much memory is allocated (bot ## What was asked, and the answer -A *terminal* is the call that ends a query and gives you the rows: `ToListAsync()`, `ToArrayAsync()`, `First()` and the like. Each row is one page. +A *terminal* is the call that ends a query and gives you the rows: `ToListAsync()`, `ToArrayAsync()`, `FirstAsync()` and the like. Each row is one page. | What we asked | The answer in a few words | Page | |---|---|---| @@ -30,7 +30,7 @@ A *terminal* is the call that ends a query and gives you the rows: `ToListAsync( | Sync reads or async reads? | Sync is cheapest or tied in every case measured; async can wait on a busy thread pool | [Sync reads against async reads](benchmarks/sync-vs-async.md) | | What happens on a slow link or with a 100 MB value? | The link sets the time; the sync read allocates less; one async path took 5.4 times as long | [Slow links and large values](benchmarks/slow-links-and-large-values.md) | | Are channels and Dataflow faster than a loop? | At 1,000 rows, yes: 0.32 and 0.72 of a plain loop's time; at one row, no: 1.6 and 2.6 times | [Channels and Dataflow against a plain loop](benchmarks/pipelines.md) | -| Which pool, and how are rows cleared? | Plain `ArrayPool` arrays; end to end, 0 to 2.5% faster for the collecting terminals and 2 to 23% for the buffer terminals than the build of 2026-11-20 (a different build on a different day); always clearing reference rows costs nothing you can measure: at 1, 100 and 10,000 rows the current build is as fast or faster than the 2026-11-20 build that cleared nothing | [Pooling and clearing](benchmarks/pooling-and-clearing.md) | +| Which pool, and how are rows cleared? | Plain `ArrayPool` arrays; clearing reference rows before an array goes back costs nothing you can measure (end to end, the build that always clears was as fast or faster than a build that cleared nothing, at 1, 100 and 10,000 rows) | [Pooling and clearing](benchmarks/pooling-and-clearing.md) | Also: [How we measure](benchmarks/how-we-measure.md) (the method, the settings, how fresh the data is), the [data files](performance-data.md), and the [interactive ranking](../benchmarks/ranking.html) of the 16 synthetic variants, a snapshot of 2026-11-23. diff --git a/docsite/articles/release-notes.md b/docsite/articles/release-notes.md index c3b1a436..ec71f075 100644 --- a/docsite/articles/release-notes.md +++ b/docsite/articles/release-notes.md @@ -43,7 +43,13 @@ Not shipped; the main ones. `Microsoft.SourceLink.GitHub` 11.0.100, `Microsoft.C There is no version 11 of the `Open.Database.Extensions.SqlClient` package (`System.Data.SqlClient`): use `Open.Database.Extensions.MSSqlClient` for SQL Server. The last release of the old package, 10.3.0, works with Core 10.x only, not with Core 11. -### Changes since rc.18 +Version 11.0.0 is the first release of version 11 that is not a release candidate. What it is, and how to move a 10.x codebase to it, is in [Coming from earlier versions](whats-new-11.md). The changes made to it after the last release candidate are the first section below. + +## Version 11 release candidates + +Only for a project that used a release candidate (`11.0.0-rc.N`): what changed from one to the next, newest first. A project that starts with 11.0.0 does not need this section. + +### Changes in 11.0.0 since rc.18 - **Changed: a return code read on a text command or a text definition no longer throws.** `ExecuteReturnAsync()` on a call of a `DbNonQuery.Text` definition, a `ReturnValue` member in `ExecuteOutputAsync()` on a text command or in `Output()` on a text definition, and `CaptureReturn` (or a captured model with a `ReturnValue` member) on a text command or a text definition threw `InvalidOperationException` ("needs a stored procedure"); they now run and give what the provider reports for a text command (SQL Server: 0, and `RETURN n` in text is a server error). A return code comes from a stored procedure called by name; from text, read it with `EXEC @r = dbo.p` and an output parameter. The command of the SQL Server package is the exception: the next item. - **Changed: the SQL Server command refuses a return code on a text command.** On an `ExpressiveSqlCommand` whose type is text, `ExecuteReturnAsync()`, `ExecuteReturnAsync()` and `ExecuteReturn()` ran and gave 0 (`RETURN n` in text was a server error), and a `ReturnValue` member in `ExecuteOutputAsync()` and `CaptureReturn` threw `InvalidOperationException` with a message about stored procedures; all of them now throw `InvalidOperationException` before a connection is used, and the message says to call the procedure by name or to read the code with `EXEC @r = dbo.p` and an output parameter. A stored procedure called by name is unchanged, and so is a definition (`DbNonQuery.Text`) on a `SqlConnection`, which gives what SQL Server reports. @@ -53,8 +59,6 @@ There is no version 11 of the `Open.Database.Extensions.SqlClient` package (`Sys - **Fixed: a canceled parameter-name lookup is no longer remembered as "no names".** When the call was canceled while the provider's `GetSchemaAsync` threw `ArgumentException`, `NotSupportedException` or `NotImplementedException`, the lookup took that as "the provider reports no names" and kept it, so later calls of the procedure did not look again; the call ends canceled (`OperationCanceledException`) and nothing is kept, as for the output-parameter metadata. - **Changed: constructing a command or calling `Command` or `StoredProcedure` on a transaction that has no connection throws `InvalidOperationException`.** The constructors that take a transaction (`ExpressiveCommand`, `ExpressiveDbCommand`, `ExpressiveSqlCommand`) and the `Command` and `StoredProcedure` extensions of `IDbTransaction` and `DbTransaction` threw `ArgumentNullException` named `connection` for a transaction that has completed; they now throw `InvalidOperationException`, with a message that says the cause and the fix, as `CreateCommand` does. A `null` transaction still throws `ArgumentNullException` named `transaction`. -## Version 11 release candidates - ### Changes since rc.17 - **Removed: the protected `PrepareCommand(TConnection)` and `ConnectionProvider` of `ExpressiveCommandBase`.** A class of your own that derives from `ExpressiveCommandBase` and called one of them no longer compiles. There is no replacement: a terminal builds the command when it runs, and a subclass that needs the connection, pool or factory keeps its own reference to what it passed to the base constructor. @@ -232,7 +236,7 @@ The [migration guide](whats-new-11.md) groups the removals by theme, with what t - Version 11 targets .NET 11: every package adds `net11.0` next to `net10.0` (LTS), `netstandard2.0` and `netstandard2.1` (`MSSqlClient`: `net472`, `net10.0` and `net11.0`). Each major version of the library targets the matching .NET. Building the repository needs the .NET 11 SDK (`global.json`). - `.SingleResult()` can be written before `Map`, so a query reads as behavior first, then shape: `command.SingleResult().Map().ToListAsync(cancellationToken)`. It works on an expressive command (`IExecuteReader`) and on a raw `IDbCommand` or `DbCommand`, with the same `Map` overloads as before, and it is the same as `command.Map().SingleResult()`, which still works. There is none on `IDataReader` or `DataTable`: their views never read through, so there is nothing to opt out of. Nothing changes by default: without it a `Map` terminal still reads through the later result sets. - **`ExecuteScalar()` and `ExecuteScalarAsync()` convert the way `Map()` does.** They cast the provider's value exactly, so a `bigint` read as `int`, or a `numeric` read as `long`, threw `InvalidCastException`, which a port from Dapper met only on a real database. Now a value that is already a `T` is returned as it is, an integer converts to another integer type with a range check, and any other value is converted by the same code `Map()` uses. `NULL` and no row still give `default(T)`. A value that cannot be converted, or does not fit, throws `ValueMappingException` with the conversion's error inside. **Behavior change:** a call that threw `InvalidCastException` now converts, or throws that exception. `ExecuteReturn()` and `ExecuteReturnAsync()` convert the same way. The overloads that take a `Func` are unchanged. -- A `RowMap` takes a converter for a column that needs a trim, a parse or a format on its way to a member: `map.Convert(nameof(Order.OrderNum), n => n.ToString("D6"))`, or `Convert(member, column, convert)` to name the column as well. It returns a new map, and the delegate runs inside the compiled row reader, so a result maps straight into the type you want, with no row type to copy from. A converter is not called for a NULL cell (the member follows the NULL rules); a `Nullable<>` `TColumn` is called with null. See [Converting a column](mapping.md#converting-a-column). +- A `RowMap` takes a converter for a column that needs a trim, a parse or a format on its way to a member: `map.Convert(nameof(Draft.DraftNo), n => n.ToString("D6"))`, or `Convert(member, column, convert)` to name the column as well. It returns a new map, and the delegate runs inside the compiled row reader, so a result maps straight into the type you want, with no row type to copy from. A converter is not called for a NULL cell (the member follows the NULL rules); a `Nullable<>` `TColumn` is called with null. See [Converting a column](mapping.md#converting-a-column). - `First()` and `Single()` (and `FirstAsync(cancellationToken)`, `SingleAsync(cancellationToken)`) on `Map()` throw `InvalidOperationException` when the query returns no row, and `Single` also when it returns more than one. An insert that returns its new id is one `await command.Map().SingleAsync(cancellationToken)`, with no handler to check the row count. The commands have the shortcuts too: `command.SingleAsync(cancellationToken)`. A `NULL` value is still a row. The error for no rows is thrown after the connection is released and the later result sets are read, so a failure in one of them comes first. See [Terminals](mapping.md#terminals). - `ToDictionary` and `ToDictionaryAsync` on `Map()` take a value selector: `ToDictionaryAsync(post => post.Id, post => post.Body ?? "")` builds the lookup in one pass, without keeping the rows. A duplicate key throws, as it does without the value selector. diff --git a/docsite/articles/shaping-rows.md b/docsite/articles/shaping-rows.md index 5c107f9d..85e4bc70 100644 --- a/docsite/articles/shaping-rows.md +++ b/docsite/articles/shaping-rows.md @@ -110,11 +110,11 @@ The Func delegates of C# stop at 16 parameters, so a lambda with more looks like [!code-csharp[](../samples/ShapingRows.cs#shape_wide_use)] -A factory takes more than 16 parameters too. +A factory takes more than 16 parameters too, through a delegate type you declare: a lambda that big has no built-in `Func` type to convert to. ## Rows you do not want -You may look for a way to skip a row before it is built: a predicate over the raw columns, or a factory that may return nothing. The library has no such feature. These are the places for the filter, best first. +You may look for a way to skip a row before it is built: a predicate over the raw columns, or a factory that drops the row. The library has no such feature: a factory can return `null`, but the row stays in the result as a `null` entry. These are the places for the filter, best first. **In the query.** The `WHERE` is the place for it: the database skips the rows, nothing is read or built for them. A column that only decides whether a row is kept belongs in the `WHERE`, not in the select list. diff --git a/docsite/articles/whats-new-11.md b/docsite/articles/whats-new-11.md index d6b7c5c0..ecd26cb3 100644 --- a/docsite/articles/whats-new-11.md +++ b/docsite/articles/whats-new-11.md @@ -137,7 +137,7 @@ The blocking calls (`Execute`, `ExecuteNonQuery`, `ExecuteScalar`, `ExecuteReade - **`AddParam(parameterName)` with a string variable** added a parameter with that name and no value in 10.x. In 11 it adds a parameter named `parameterName` whose value is the string. A literal, `AddParam("name")`, throws `ArgumentException`. - **Names from arguments.** `.AddParam(author)` takes the name from the variable and matches it to the stored procedure's real name. `AddParam("name", value)` always wins. -- **A typed NULL** such as `AddParam("@id", (long?)null)` is sent with the database type of its overload. +- **A typed `null`** such as `AddParam("@id", (long?)null)` is sent with the database type of its overload. - **After a run, `Params` holds what you added,** under the names as added. Read the provider command's `Parameters` in `Execute(command => ...)` to see what was sent. - **No direction on the chain.** `AddParam`, `AddParamIf` and `AddReturnParam` no longer take a `ParameterDirection`, so a parameter added on the chain is an input; `AddReturnParam` is gone. Calls that never passed a direction compile unchanged; `AddParam(name, direction)`, `AddParamIf(condition, name, direction)`, `AddParam(name, type)` and `AddParamIf(condition, name, type)` are now compile errors that say what to do instead. The forms that took a direction after the value, `AddParam(name, value, ParameterDirection)` and `AddParam(name, value, type, direction)` (the SQL Server forms with a database type and a direction too), fail to compile with the compiler's own argument error, without a message of their own: use the raw `AddParameter` inside `ExecuteAsync(command => ...)`, or read the output with `ExecuteOutputAsync`. To set a direction, use `ExecuteAsync(command => ...)` with the raw `AddParameter`, `AddParameterType` and `AddReturnParameter` extensions. `Param` has no `direction` constructor parameter and no `Direction` property. - **Output parameters into a model.** `ExecuteOutputAsync()` reads a command's output parameters and return code into a model by name (`ExecuteOutputAsync(name)` for one value): see [Output parameters](expressive-commands.md#output-parameters). diff --git a/docsite/images/asyncreads-flow.svg b/docsite/images/asyncreads-flow.svg index 1d023b83..dad98ee4 100644 --- a/docsite/images/asyncreads-flow.svg +++ b/docsite/images/asyncreads-flow.svg @@ -1,6 +1,6 @@ Where a thread waits: Read() against ReadAsync - Two lanes read left to right, the default on top and the opt-in below, with the same stages in the same places. In both lanes the command executes and the connection opens asynchronously, so the thread is released while each awaits. Then the rows. Default lane: the thread reads two rows with Read, then waits for a row that is still on the network; the thread is blocked there; then it reads the next row. Opt-in lane, AsyncReads: ReadAsync is called for two rows, then for a row still on the network it returns an incomplete task; the thread is released and the continuation resumes when the row arrives. A caption says the sync default holds the thread while a row is on the wire; the opt-in releases it, and pays for the state machine. The figure has no numbers. + Two lanes read left to right, the default on top and the opt-in below, with the same stages in the same places. In both lanes the connection opens and the command executes asynchronously, so the thread is released while each awaits. Then the rows. Default lane: the thread reads two rows with Read, then waits for a row that is still on the network; the thread is blocked there; then it reads the next row. Opt-in lane, AsyncReads: ReadAsync is called for two rows, then for a row still on the network it returns an incomplete task; the thread is released and the continuation resumes when the row arrives. A caption says the sync default holds the thread while a row is on the wire; the opt-in releases it, and pays for the state machine. The figure has no numbers. as raw HTML, ends the packages section at a level 1 or 2 heading outside a fence, compares against the Core README; docs.yml runs it before the link check so a README error is not hidden by a link failure. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/docs.yml | 6 +++--- docsite/articles/expressive-commands.md | 4 ++-- docsite/articles/release-notes.md | 4 ++-- docsite/samples/Mapping.cs | 4 ++-- docsite/tools/check-readmes.ps1 | 16 +++++++++++----- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f9267104..3775627b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -63,12 +63,12 @@ jobs: if ($apiPages -lt 100) { throw "Only $apiPages API pages were generated" } "Site has $apiPages API pages." - - 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 - - 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 + - name: Summarize warnings if: always() continue-on-error: true diff --git a/docsite/articles/expressive-commands.md b/docsite/articles/expressive-commands.md index bb56afe8..04f2b5f6 100644 --- a/docsite/articles/expressive-commands.md +++ b/docsite/articles/expressive-commands.md @@ -115,7 +115,7 @@ A command is not safe to share across threads: one built from a single connectio | `DbConnection`, `DbTransaction`, `IDbConnectionFactory` | `ExpressiveDbCommand` | `DbDataReader` (async reads) | | `SqlConnection` or a `SqlConnectionFactory` (MSSqlClient package) | `ExpressiveSqlCommand` | `SqlDataReader` | -Choose by what you need: only the last two rows read with `ReadAsync` and have `ExecuteNonQueryAsync` and `ExecuteScalarAsync`, so a service that awaits starts from a `DbConnection` or an `IDbConnectionFactory` (for example `IDbConnectionFactory`). Pass a `CommandType` as the second argument of `Command` if you need `TableDirect`. +Choose by what you need: only the last two rows have `ExecuteNonQueryAsync` and `ExecuteScalarAsync`, so a service that awaits starts from a `DbConnection` or an `IDbConnectionFactory` (for example `IDbConnectionFactory`). Pass a `CommandType` as the second argument of `Command` if you need `TableDirect`. ## Parameters @@ -183,7 +183,7 @@ What sharing means for names kept for the whole process: #### What was sent? -`command.Params` always lists what you added: a name you wrote as written, an argument-derived name as its last member, and the members of an `AddParams` object under their member names. A run never changes it. The real names are worked out in every run, for the connection that run uses, so one command object can run against two databases that name the parameters of a procedure differently. To see what the run sent, give `ExecuteAsync(command => ...)` a function that reads the provider's command: its `CommandText`, `CommandType` and `Parameters` (name and value of each) already have the real names. The library keeps no log of the statement and has no other hook. +`command.Params` always lists what you added: a name you wrote as written, an argument-derived name as its last member, and the members of an `AddParams` object under their member names. A run never changes it. The real names are worked out in every run, for the connection that run uses, so one command object can run against two databases that name the parameters of a procedure differently. To see what the run sent, give `ExecuteAsync(command => ...)` a function that reads the provider's command and returns a `ValueTask`: its `CommandText`, `CommandType` and `Parameters` (name and value of each) already have the real names. The library keeps no log of the statement and has no other hook. A derived name stays as written when no real names were read: a text command, another provider, a procedure name with a database part (`otherdb.dbo.proc`), a procedure the login cannot see or that does not exist, or one that declares no parameters. Name the parameters yourself when you call a procedure in another database. diff --git a/docsite/articles/release-notes.md b/docsite/articles/release-notes.md index ec71f075..849c1d64 100644 --- a/docsite/articles/release-notes.md +++ b/docsite/articles/release-notes.md @@ -47,7 +47,7 @@ Version 11.0.0 is the first release of version 11 that is not a release candidat ## Version 11 release candidates -Only for a project that used a release candidate (`11.0.0-rc.N`): what changed from one to the next, newest first. A project that starts with 11.0.0 does not need this section. +Only for a project that used a release candidate (`11.0.0-rc.N`): what changed from one to the next, newest first. It starts with 11.0.0 itself. A project that starts with 11.0.0 does not need this section. ### Changes in 11.0.0 since rc.18 @@ -236,7 +236,7 @@ The [migration guide](whats-new-11.md) groups the removals by theme, with what t - Version 11 targets .NET 11: every package adds `net11.0` next to `net10.0` (LTS), `netstandard2.0` and `netstandard2.1` (`MSSqlClient`: `net472`, `net10.0` and `net11.0`). Each major version of the library targets the matching .NET. Building the repository needs the .NET 11 SDK (`global.json`). - `.SingleResult()` can be written before `Map`, so a query reads as behavior first, then shape: `command.SingleResult().Map().ToListAsync(cancellationToken)`. It works on an expressive command (`IExecuteReader`) and on a raw `IDbCommand` or `DbCommand`, with the same `Map` overloads as before, and it is the same as `command.Map().SingleResult()`, which still works. There is none on `IDataReader` or `DataTable`: their views never read through, so there is nothing to opt out of. Nothing changes by default: without it a `Map` terminal still reads through the later result sets. - **`ExecuteScalar()` and `ExecuteScalarAsync()` convert the way `Map()` does.** They cast the provider's value exactly, so a `bigint` read as `int`, or a `numeric` read as `long`, threw `InvalidCastException`, which a port from Dapper met only on a real database. Now a value that is already a `T` is returned as it is, an integer converts to another integer type with a range check, and any other value is converted by the same code `Map()` uses. `NULL` and no row still give `default(T)`. A value that cannot be converted, or does not fit, throws `ValueMappingException` with the conversion's error inside. **Behavior change:** a call that threw `InvalidCastException` now converts, or throws that exception. `ExecuteReturn()` and `ExecuteReturnAsync()` convert the same way. The overloads that take a `Func` are unchanged. -- A `RowMap` takes a converter for a column that needs a trim, a parse or a format on its way to a member: `map.Convert(nameof(Draft.DraftNo), n => n.ToString("D6"))`, or `Convert(member, column, convert)` to name the column as well. It returns a new map, and the delegate runs inside the compiled row reader, so a result maps straight into the type you want, with no row type to copy from. A converter is not called for a NULL cell (the member follows the NULL rules); a `Nullable<>` `TColumn` is called with null. See [Converting a column](mapping.md#converting-a-column). +- A `RowMap` takes a converter for a column that needs a trim, a parse or a format on its way to a member: `map.Convert(nameof(Order.OrderNum), n => n.ToString("D6"))`, or `Convert(member, column, convert)` to name the column as well. It returns a new map, and the delegate runs inside the compiled row reader, so a result maps straight into the type you want, with no row type to copy from. A converter is not called for a NULL cell (the member follows the NULL rules); a `Nullable<>` `TColumn` is called with null. See [Converting a column](mapping.md#converting-a-column). - `First()` and `Single()` (and `FirstAsync(cancellationToken)`, `SingleAsync(cancellationToken)`) on `Map()` throw `InvalidOperationException` when the query returns no row, and `Single` also when it returns more than one. An insert that returns its new id is one `await command.Map().SingleAsync(cancellationToken)`, with no handler to check the row count. The commands have the shortcuts too: `command.SingleAsync(cancellationToken)`. A `NULL` value is still a row. The error for no rows is thrown after the connection is released and the later result sets are read, so a failure in one of them comes first. See [Terminals](mapping.md#terminals). - `ToDictionary` and `ToDictionaryAsync` on `Map()` take a value selector: `ToDictionaryAsync(post => post.Id, post => post.Body ?? "")` builds the lookup in one pass, without keeping the rows. A duplicate key throws, as it does without the value selector. diff --git a/docsite/samples/Mapping.cs b/docsite/samples/Mapping.cs index 824bb17a..d1c26390 100644 --- a/docsite/samples/Mapping.cs +++ b/docsite/samples/Mapping.cs @@ -721,8 +721,8 @@ public static class DraftMaps // the column is the one the member matches by name // (draft_no feeds DraftNo, ignoring underscores). // Convert(member, column, convert) - // names the column too, for scheduled_at, - // which matches no property. + // names the column too, here scheduled_at + // (which the name match would also find). // The delegate runs inside the compiled row reader, once per row, // and is never called for a NULL cell: // ScheduledAt and Reviewer are string?, so a NULL gives null. diff --git a/docsite/tools/check-readmes.ps1 b/docsite/tools/check-readmes.ps1 index d5f528aa..350cfbc1 100644 --- a/docsite/tools/check-readmes.ps1 +++ b/docsite/tools/check-readmes.ps1 @@ -58,21 +58,27 @@ foreach ($readme in $readmes) { # Image hosts. $text = $lines -join "`n" - $images = @([regex]::Matches($text, '!\[[^\]]*\]\((https?://[^)\s]+)\)') | ForEach-Object { $_.Groups[1].Value }) + - @([regex]::Matches($text, ']*\bsrc\s*=\s*"([^"]+)"', 'IgnoreCase') | ForEach-Object { $_.Groups[1].Value }) + $prose = [regex]::Replace($text, '(?ms)^[ \t]*(```|~~~).*?^[ \t]*\1', '') + $prose = [regex]::Replace($prose, '`[^`\r\n]*`', '') # inline code is not markup + $images = @([regex]::Matches($prose, '!\[[^\]]*\]\(\s*]+)>?(?:\s+"[^"]*")?\s*\)') | ForEach-Object { $_.Groups[1].Value }) + + @([regex]::Matches($prose, ']*?\bsrc\s*=\s*(?:"([^"]*)"|''([^'']*)''|([^\s>]+))', 'IgnoreCase') | ForEach-Object { ($_.Groups[1].Value, $_.Groups[2].Value, $_.Groups[3].Value | Where-Object { $_ })[0] }) foreach ($url in $images) { + if ($url -notmatch '^https://') { $errors.Add("${readme}: image '$url' must be an absolute https URL (nuget.org does not render a relative path)"); continue } $uriHost = ([uri]$url).Host if ($uriHost -notin $allowedHosts) { $errors.Add("${readme}: image host '$uriHost' is not one nuget.org renders ($url)") } } - if ($text -match '(?i)<(?:picture|video|iframe|details|div|table|p)\b') { $errors.Add("${readme}: raw HTML block tag; use Markdown only") } + # Markdown only: the one HTML tag a README may carry is . + if ([regex]::IsMatch(($prose -replace ']*>', '' -replace '\s]+>', ''), '<[a-zA-Z/][^>]*>')) { $errors.Add("${readme}: raw HTML tag; use Markdown only") } # "The packages": from its heading to the next heading or the bold line that follows the sentence, with the # row of this package turned into a plain row so that the five can be compared. $start = [array]::IndexOf($lines, '## The packages') if ($start -lt 0) { $errors.Add("${readme}: no '## The packages' section"); continue } $block = [System.Collections.Generic.List[string]]::new() + $inFence = $false for ($j = $start; $j -lt $lines.Count; $j++) { - if ($j -gt $start -and ($lines[$j].StartsWith('## ') -or $lines[$j].StartsWith('**Coming from') -or $lines[$j].StartsWith('[Documentation]'))) { break } + if ($lines[$j] -match '^\s*(```|~~~)') { $inFence = -not $inFence } + if ($j -gt $start -and -not $inFence -and ($lines[$j] -match '^#{1,2}\s' -or $lines[$j].StartsWith('**Coming from') -or $lines[$j].StartsWith('[Documentation]'))) { break } $block.Add($lines[$j]) } $normal = ($block -join "`n").Trim() -replace '\*\*(Open\.Database\.Extensions[A-Za-z.]*)\*\* \(this package\)', '[$1](https://www.nuget.org/packages/$1/)' @@ -80,7 +86,7 @@ foreach ($readme in $readmes) { $sections[$readme] = $normal } -$reference = $sections.Values | Select-Object -First 1 +$reference = $sections[$readmes[0]] foreach ($readme in $sections.Keys) { if ($sections[$readme] -ne $reference) { $errors.Add("${readme}: the 'The packages' section differs from the other READMEs (it must be identical in all five)") } } From 23865b829772cbca9cce79d0e53deb09c5953b43 Mon Sep 17 00:00:00 2001 From: electricessence <5899455+electricessence@users.noreply.github.com> Date: Sat, 5 Dec 2026 20:18:49 -0800 Subject: [PATCH 3/6] Apply the owner's settled decisions on the docs pass: buffer first, one cited run per number, no orphan page, fewer repeats - async-buffers, channels-and-dataflow: the buffer is the recommended way to read rows once; a stream is for stopping early or feeding a pipeline; Stream and StreamBuffered hold the connection and are the last resort - real-databases, library-comparison, performance: each Dapper figure names its run and data file (14.9% from run rp-sql-w20 in real-providers.csv; 11% from runs a and b of library-real.csv) - delete docsite/api/overview/Open.Database.Extensions.Core.md: the namespace has no public types - trim repeats in async-reads, async-buffers and channels-and-dataflow (the figure numbers stay in the alt text and the Sources table) Co-Authored-By: Claude Sonnet 5.5 --- docsite/api/overview/Open.Database.Extensions.Core.md | 5 ----- docsite/articles/async-buffers.md | 7 +++---- docsite/articles/async-reads.md | 4 +--- docsite/articles/benchmarks/library-comparison.md | 2 +- docsite/articles/benchmarks/real-databases.md | 2 +- docsite/articles/channels-and-dataflow.md | 4 ++-- docsite/articles/performance.md | 2 +- 7 files changed, 9 insertions(+), 17 deletions(-) delete mode 100644 docsite/api/overview/Open.Database.Extensions.Core.md diff --git a/docsite/api/overview/Open.Database.Extensions.Core.md b/docsite/api/overview/Open.Database.Extensions.Core.md deleted file mode 100644 index e85ece46..00000000 --- a/docsite/api/overview/Open.Database.Extensions.Core.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -uid: Open.Database.Extensions.Core -summary: *content ---- -Support types for the row mappers and buffers. Most applications use the extensions in and never name these types. diff --git a/docsite/articles/async-buffers.md b/docsite/articles/async-buffers.md index 79a07e6d..5aaec03c 100644 --- a/docsite/articles/async-buffers.md +++ b/docsite/articles/async-buffers.md @@ -17,7 +17,7 @@ The query is read with the same read as every other terminal: `Read()` by defaul
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.
-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 @@ -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 diff --git a/docsite/articles/async-reads.md b/docsite/articles/async-reads.md index e09d80f8..7d470159 100644 --- a/docsite/articles/async-reads.md +++ b/docsite/articles/async-reads.md @@ -4,9 +4,7 @@ Every command-level terminal and mapped view reads its rows with `Read()`, and t ## The default, stated plainly -This covers every terminal on a command (`cmd.Map().ToListAsync(token)`, `FirstOrDefaultAsync`, `ToArrayAsync` and the others), and every mapped view: `Map()` and `Map(Func)`, on an expressive command and on a plain `IDbCommand`. The connection still opens, and the command still executes, asynchronously. Only the rows are read with `Read()`. - -`AsyncReads()` opts one call in to `ReadAsync(token)`, with synchronous getters. It changes only the row read: every async terminal reads through the later result sets with `NextResultAsync(token)`, with or without it. +This covers every terminal on a command (`cmd.Map().ToListAsync(token)`, `FirstOrDefaultAsync`, `ToArrayAsync` and the others), and every mapped view: `Map()` and `Map(Func)`, on an expressive command and on a plain `IDbCommand`. The raw reader extensions stay raw. The async members you call on a reader you opened (`AsAsyncEnumerable`, `SelectAsync`, `ForEachAsync` and `IterateWhileAsync`) read with `ReadAsync`: there you opened the reader and asked to iterate it asynchronously. `ForEachAsync` and `IterateWhileAsync` also have a form with a `useReadAsync` flag; pass `false` to read with `Read`. diff --git a/docsite/articles/benchmarks/library-comparison.md b/docsite/articles/benchmarks/library-comparison.md index 74d19824..70885e92 100644 --- a/docsite/articles/benchmarks/library-comparison.md +++ b/docsite/articles/benchmarks/library-comparison.md @@ -64,7 +64,7 @@ ODX is at or below Dapper's time in all 54 cases of that run, and a tie in a few ## Where the gain does not survive -Once a real provider does the work, most of the time is the provider's. SQL Server LocalDB reads 10,000 rows in 25 to 29 ms whichever library maps them, so a 2.6-times lead on a synthetic reader becomes a lead of 11%. If your queries are slow because of the database, no mapping library will change that. The thing ODX still changes there is memory: on SQL Server 22.7% less than Dapper (Dapper allocates 29.4% more), on SQLite 15.4% less (Dapper allocates 18.2% more). +Once a real provider does the work, most of the time is the provider's. SQL Server LocalDB reads 10,000 rows in 25 to 29 ms whichever library maps them, so a 2.6-times lead on a synthetic reader becomes a lead of 11% (runs a and b of [library-real.csv](../../perf-data/library-real.csv), 2026-11-23). If your queries are slow because of the database, no mapping library will change that. The thing ODX still changes there is memory: on SQL Server 22.7% less than Dapper (Dapper allocates 29.4% more), on SQLite 15.4% less (Dapper allocates 18.2% more). ## Limits diff --git a/docsite/articles/benchmarks/real-databases.md b/docsite/articles/benchmarks/real-databases.md index faf51405..4bd9643b 100644 --- a/docsite/articles/benchmarks/real-databases.md +++ b/docsite/articles/benchmarks/real-databases.md @@ -4,7 +4,7 @@ ## In short -- **On SQL Server LocalDB, `Map()` ties with hand-written code and is ahead of Dapper.** For 10,000 rows of 20 columns it took 25.6 ms, a hand-written selector 25.5 ms and Dapper 29.4 ms, which is 14.9% longer than `Map()` (the error margins do not overlap). BenchmarkDotNet's own error margin on the 20-column SQL Server runs is 2.7 to 4.9% of the mean (the tables show each one), so the gap to hand-written code is not a result. +- **On SQL Server LocalDB, `Map()` ties with hand-written code and is ahead of Dapper.** For 10,000 rows of 20 columns it took 25.6 ms, a hand-written selector 25.5 ms and Dapper 29.4 ms, which is 14.9% longer than `Map()` (the error margins do not overlap; run `rp-sql-w20` of 2026-11-23, [real-providers.csv](../../perf-data/real-providers.csv)). The two runs of the same day on [ODX against Dapper](library-comparison.md#on-real-databases) (`library-real.csv`) measured Dapper 11% longer (26.13 against 29.01 ms, and 26.07 against 28.84). BenchmarkDotNet's own error margin on the 20-column SQL Server runs is 2.7 to 4.9% of the mean (the tables show each one), so the gap to hand-written code is not a result. - **`Map()` allocates less than Dapper on both databases.** On SQL Server `Map()` allocates 9.48 MB, the same as hand-written code; Dapper allocates 12.27 MB, 29.4% more. On SQLite `Map()` allocates 12.51 MB: 15.4% less than Dapper (14.79) and 4.6% more than hand-written code (11.96). - **On SQLite `Map()` is behind hand-written code and ahead of Dapper.** `Map()` is 4.8% slower than a hand-written selector at 20 columns (27.9 against 26.6 ms, within the error margins) and 15.1% slower at 5 columns. It is 23.2% faster than Dapper at 20 columns and 26.4% faster at 5. Dapper's 20-column SQLite figure here (36.3 ms) is higher than in the two runs on [ODX against Dapper and hand-written code](library-comparison.md#on-real-databases), where it is 29.8 ms against 27.7 ms for `Map()`. diff --git a/docsite/articles/channels-and-dataflow.md b/docsite/articles/channels-and-dataflow.md index 45e1d54d..511b2b88 100644 --- a/docsite/articles/channels-and-dataflow.md +++ b/docsite/articles/channels-and-dataflow.md @@ -12,7 +12,7 @@ Both packages take a mapped query (`Map()`), so rows are mapped the same way ## Streaming from a mapped query -To read a mapped query while a consumer works, use the pooled streams (`ToPooledStream` and `ToPooledBufferStream`) in the core package: the connection is released as soon as the last row is read. +To read a query once, a buffer is the recommended way ([Pooled buffers and streams](async-buffers.md)). A pooled stream (`ToPooledStream` and `ToPooledBufferStream`, in the core package) is for a pipeline, or for stopping early. A stream earns its place when a producer and its consumer run at different speeds. After `Map()`, the query is the producer: it reads the rows on a background task, in chunks, and is finished with the connection as soon as the last row is read. The consumer does the slow work (a web call, a file write, a transform) while the query is still being read. The rows are typed, the later result sets are read through, and rows are read with `Read` unless you call `AsyncReads()`. @@ -48,7 +48,7 @@ To read rows one at a time and stop early, see [`Stream`](mapping.md#terminals): ### What it costs -The producer is unbounded. It never waits for the consumer, so the read finishes at the provider's pace and frees the connection, while memory grows with the backlog of a slow consumer. To cap memory by holding the connection, see [Channels](#channels). +The producer is unbounded: memory grows with the backlog of a slow consumer. To cap memory by holding the connection, see [Channels](#channels). ## Channels diff --git a/docsite/articles/performance.md b/docsite/articles/performance.md index 437c85c2..d3909dfa 100644 --- a/docsite/articles/performance.md +++ b/docsite/articles/performance.md @@ -8,7 +8,7 @@ The `Map()` figures on these pages were measured with [`SequentialAccess()`]( - **With no database in the way**, `Map()` holds the connection open for **2.6 times less time** than Dapper (76.1 against 199.9 µs) and allocates **2.4 times less memory** (227.4 against 548.1 KB). 20 columns, 1,000 rows, synthetic reader. - **Against hand-written code** it takes 1.9 times as long as a hand-written selector (the function you pass to `Map(selector)` that reads one row into your type, 40.7 µs) and allocates the same memory. -- **On a real database the gap is small, and still in ODX's favor.** For 10,000 rows of 20 columns Dapper took 11% longer than `Map()` on SQL Server LocalDB and 8% longer on a SQLite file (two runs each, with no overlap between the error margins in any of the four). What you can count on is memory: Dapper allocates 29.4% more on SQL Server and 18.2% more on SQLite. +- **On a real database the gap is small, and still in ODX's favor.** For 10,000 rows of 20 columns Dapper took 11% longer than `Map()` on SQL Server LocalDB and 8% longer on a SQLite file (two runs each on 2026-11-23, [library-real.csv](../perf-data/library-real.csv), with no overlap between the error margins in any of the four). What you can count on is memory: Dapper allocates 29.4% more on SQL Server and 18.2% more on SQLite. - **Where ODX is not faster:** Dapper.AOT and a hand-written selector hold the connection 29% and 47% less time than `Map()` on the synthetic reader (on a real database the hand-written selector takes about 6% less, and Dapper.AOT is level on SQL Server and 3% slower on SQLite); the opt-in async read costs more than the default; channels and Dataflow are slower than a plain loop for one row. [The full list is below.](#where-it-is-not-faster) - **Reading rows synchronously is the default on purpose.** Over a real link it took the same time as a raw SqlClient `ReadAsync()` loop, and on `Map(Func)` it allocated 42% less memory. From 0c991044c595449a6d021f71349ebe8662665c9f Mon Sep 17 00:00:00 2001 From: electricessence <5899455+electricessence@users.noreply.github.com> Date: Sat, 5 Dec 2026 20:19:43 -0800 Subject: [PATCH 4/6] Name the read mode of the benchmarked build on the performance page The 2026-11-23 figures are from build 6a770e8, where Map() read with SequentialAccess (MappedQuery.Behavior: only a selector source used the default mode). The page now says so and that Map() now reads with the default mode, with SequentialAccess() as the opt-in. Co-Authored-By: Claude Sonnet 5.5 --- docsite/articles/performance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docsite/articles/performance.md b/docsite/articles/performance.md index d3909dfa..4022380e 100644 --- a/docsite/articles/performance.md +++ b/docsite/articles/performance.md @@ -2,7 +2,7 @@ ODX is built on one idea: hold the connection open for as short a time as possible, and allocate as little as possible while it is open. -The `Map()` figures on these pages were measured with [`SequentialAccess()`](expressive-commands.md#sequential-access-for-very-large-values). +The `Map()` figures on these pages are from build `6a770e8` (2026-11-23), where `Map()` read with sequential access. It now reads with the default access mode, and [`SequentialAccess()`](expressive-commands.md#sequential-access-for-very-large-values) opts in; `Map(selector)` read with the default mode in that run. ## In short From 8510c2b2f0caa48cb7663c9428c4db37be3f5d70 Mon Sep 17 00:00:00 2001 From: electricessence <5899455+electricessence@users.noreply.github.com> Date: Sat, 5 Dec 2026 20:21:13 -0800 Subject: [PATCH 5/6] Say the read mode of the benchmarked build in one sentence Co-Authored-By: Claude Sonnet 5.5 --- docsite/articles/performance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docsite/articles/performance.md b/docsite/articles/performance.md index 4022380e..8a031b4d 100644 --- a/docsite/articles/performance.md +++ b/docsite/articles/performance.md @@ -2,7 +2,7 @@ ODX is built on one idea: hold the connection open for as short a time as possible, and allocate as little as possible while it is open. -The `Map()` figures on these pages are from build `6a770e8` (2026-11-23), where `Map()` read with sequential access. It now reads with the default access mode, and [`SequentialAccess()`](expressive-commands.md#sequential-access-for-very-large-values) opts in; `Map(selector)` read with the default mode in that run. +The `Map()` figures on these pages are from build `6a770e8` (2026-11-23), measured with sequential access; `Map()` reads with the default mode unless you add [`SequentialAccess()`](expressive-commands.md#sequential-access-for-very-large-values), and `Map(selector)` was measured with the default mode. ## In short From 2d46a955cad2ae550da198c1b6643183b8bd9451 Mon Sep 17 00:00:00 2001 From: electricessence <5899455+electricessence@users.noreply.github.com> Date: Sat, 5 Dec 2026 20:28:41 -0800 Subject: [PATCH 6/6] Fix the four findings of the final swarm: release-notes pointer, ExecuteAsync in whats-new, a list in CONTRIBUTING-DOCS, the cross-build caveat on the clearing row Co-Authored-By: Claude Sonnet 5.5 --- docsite/CONTRIBUTING-DOCS.md | 2 +- docsite/articles/performance.md | 2 +- docsite/articles/release-notes.md | 2 +- docsite/articles/whats-new-11.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docsite/CONTRIBUTING-DOCS.md b/docsite/CONTRIBUTING-DOCS.md index 69ad54e7..17717cbc 100644 --- a/docsite/CONTRIBUTING-DOCS.md +++ b/docsite/CONTRIBUTING-DOCS.md @@ -14,4 +14,4 @@ Every push to `master` rebuilds and publishes the site (`.github/workflows/docs. - **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). - **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 or a broken link or a package README that breaks its rules does, and the live site stays as it was. +- **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. diff --git a/docsite/articles/performance.md b/docsite/articles/performance.md index 8a031b4d..6a44b415 100644 --- a/docsite/articles/performance.md +++ b/docsite/articles/performance.md @@ -30,7 +30,7 @@ A *terminal* is the call that ends a query and gives you the rows: `ToListAsync( | Sync reads or async reads? | Sync is cheapest or tied in every case measured; async can wait on a busy thread pool | [Sync reads against async reads](benchmarks/sync-vs-async.md) | | What happens on a slow link or with a 100 MB value? | The link sets the time; the sync read allocates less; one async path took 5.4 times as long | [Slow links and large values](benchmarks/slow-links-and-large-values.md) | | Are channels and Dataflow faster than a loop? | At 1,000 rows, yes: 0.32 and 0.72 of a plain loop's time; at one row, no: 1.6 and 2.6 times | [Channels and Dataflow against a plain loop](benchmarks/pipelines.md) | -| Which pool, and how are rows cleared? | Plain `ArrayPool` arrays; clearing reference rows before an array goes back costs nothing you can measure (end to end, the build that always clears was as fast or faster than a build that cleared nothing, at 1, 100 and 10,000 rows) | [Pooling and clearing](benchmarks/pooling-and-clearing.md) | +| Which pool, and how are rows cleared? | Plain `ArrayPool` arrays; clearing reference rows before an array goes back costs nothing you can measure (end to end, the build that always clears took less time than a build that cleared nothing, at 1, 100 and 10,000 rows; two builds on different days, so read it as "clearing does not cost time you can see") | [Pooling and clearing](benchmarks/pooling-and-clearing.md) | Also: [How we measure](benchmarks/how-we-measure.md) (the method, the settings, how fresh the data is), the [data files](performance-data.md), and the [interactive ranking](../benchmarks/ranking.html) of the 16 synthetic variants, a snapshot of 2026-11-23. diff --git a/docsite/articles/release-notes.md b/docsite/articles/release-notes.md index 849c1d64..dfd902f2 100644 --- a/docsite/articles/release-notes.md +++ b/docsite/articles/release-notes.md @@ -43,7 +43,7 @@ Not shipped; the main ones. `Microsoft.SourceLink.GitHub` 11.0.100, `Microsoft.C There is no version 11 of the `Open.Database.Extensions.SqlClient` package (`System.Data.SqlClient`): use `Open.Database.Extensions.MSSqlClient` for SQL Server. The last release of the old package, 10.3.0, works with Core 10.x only, not with Core 11. -Version 11.0.0 is the first release of version 11 that is not a release candidate. What it is, and how to move a 10.x codebase to it, is in [Coming from earlier versions](whats-new-11.md). The changes made to it after the last release candidate are the first section below. +Version 11.0.0 is the first release of version 11 that is not a release candidate. What it is, and how to move a 10.x codebase to it, is in [Coming from earlier versions](whats-new-11.md). The changes made to it after the last release candidate are at the start of [Version 11 release candidates](#version-11-release-candidates), because only a project that used a release candidate needs them. ## Version 11 release candidates diff --git a/docsite/articles/whats-new-11.md b/docsite/articles/whats-new-11.md index ecd26cb3..72c5736f 100644 --- a/docsite/articles/whats-new-11.md +++ b/docsite/articles/whats-new-11.md @@ -138,7 +138,7 @@ The blocking calls (`Execute`, `ExecuteNonQuery`, `ExecuteScalar`, `ExecuteReade - **`AddParam(parameterName)` with a string variable** added a parameter with that name and no value in 10.x. In 11 it adds a parameter named `parameterName` whose value is the string. A literal, `AddParam("name")`, throws `ArgumentException`. - **Names from arguments.** `.AddParam(author)` takes the name from the variable and matches it to the stored procedure's real name. `AddParam("name", value)` always wins. - **A typed `null`** such as `AddParam("@id", (long?)null)` is sent with the database type of its overload. -- **After a run, `Params` holds what you added,** under the names as added. Read the provider command's `Parameters` in `Execute(command => ...)` to see what was sent. +- **After a run, `Params` holds what you added,** under the names as added. Read the provider command's `Parameters` in `ExecuteAsync(command => ...)` to see what was sent. - **No direction on the chain.** `AddParam`, `AddParamIf` and `AddReturnParam` no longer take a `ParameterDirection`, so a parameter added on the chain is an input; `AddReturnParam` is gone. Calls that never passed a direction compile unchanged; `AddParam(name, direction)`, `AddParamIf(condition, name, direction)`, `AddParam(name, type)` and `AddParamIf(condition, name, type)` are now compile errors that say what to do instead. The forms that took a direction after the value, `AddParam(name, value, ParameterDirection)` and `AddParam(name, value, type, direction)` (the SQL Server forms with a database type and a direction too), fail to compile with the compiler's own argument error, without a message of their own: use the raw `AddParameter` inside `ExecuteAsync(command => ...)`, or read the output with `ExecuteOutputAsync`. To set a direction, use `ExecuteAsync(command => ...)` with the raw `AddParameter`, `AddParameterType` and `AddReturnParameter` extensions. `Param` has no `direction` constructor parameter and no `Direction` property. - **Output parameters into a model.** `ExecuteOutputAsync()` reads a command's output parameters and return code into a model by name (`ExecuteOutputAsync(name)` for one value): see [Output parameters](expressive-commands.md#output-parameters). - **Output parameters beside rows.** `CaptureOutput`, `CaptureOutputDecimal` and `CaptureReturn` on a command or a mapped query give a `DbCapture` that the async terminal fills, so one call returns rows and outputs: see [Output parameters beside rows](expressive-commands.md#output-parameters-beside-rows).