Repository navigation
Add async members to SafeDataReader - #4976
Merged
Merged
Conversation
SafeDataReader gets ReadAsync, NextResultAsync, CloseAsync, IsDBNullAsync, GetFieldValueAsync<T>, null-safe async getters (GetStringAsync, GetInt32Async and the rest) and DisposeAsync. They use the underlying DbDataReader, and run synchronously when the wrapped reader isn't one. SafeSqlDataReader now inherits ReadAsync, NextResultAsync and GetFieldValueAsync<T> from SafeDataReader, and IsDbNullAsync is obsolete in favor of IsDBNullAsync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Async disposal can skip subclasses’ unmanaged-resource cleanup, and the upgrade guide omits required source-compatibility changes.
2 open issues
What changed in this PR
Adds async support to CSLA’s SafeDataReader, addressing #4975 while preserving null-safe typed getters and synchronous fallback for readers that are not DbDataReader.
Changes:
- Adds async navigation, value access, closing, and disposal.
- Moves shared async methods from
SafeSqlDataReaderinto the base reader and deprecatesIsDbNullAsync. - Adds SQLite-backed tests and documents the new APIs and migration requirements.
| File | Description |
|---|---|
| Source/tests/Csla.test/SafeDataReader/SafeDataReaderAsyncTests.cs | Tests async getters, navigation, cancellation, cleanup, and fallback behavior. |
| Source/Csla/Data/SafeDataReader.cs | Implements async reader APIs and IAsyncDisposable. |
| Source/Csla.Data.SqlClient.Fx/SafeSqlDataReader.cs | Inherits shared async methods and retains obsolete null-check aliases. |
| releasenotes.md | Announces async support and compatibility changes. |
| docs/Upgrading to CSLA 11.md | Provides usage examples and migration guidance. |
Review effort: Balanced
…(false) from DisposeAsync Name the async ordinal parameters ordinal and give ReadAsync, NextResultAsync, IsDBNullAsync(int) and GetFieldValueAsync<T>(int) overloads with and without a CancellationToken, so code written against SafeSqlDataReader still compiles. DisposeAsync now calls Dispose(false) so subclass cleanup runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
SafeDataReaderhas async members:ReadAsync,NextResultAsyncandCloseAsync.IsDBNullAsyncandGetFieldValueAsync<T>, by ordinal or by column name.GetStringAsync,GetValueAsync,GetInt16/32/64Async,GetDoubleAsync,GetFloatAsync,GetDecimalAsync,GetBooleanAsync,GetByteAsync,GetGuidAsync,GetDateTimeAsync,GetDateTimeOffsetAsyncandGetSmartDateAsync.IAsyncDisposable(DisposeAsync).DbDataReader, which every ADO.NET provider returns. If the wrapped reader isn't aDbDataReader, they run synchronously.(T)cast would fail where a provider returns a different type: SQLite returnslongfor INTEGER columns.SafeSqlDataReadernow inheritsReadAsync,NextResultAsyncandGetFieldValueAsync<T>instead of declaring SqlClient-only versions. It keepsIsDbNullAsync, marked[Obsolete], which forwards toIsDBNullAsync.SafeSqlDataReaderasync methods must be recompiled. Source code is unchanged.Upgrading to CSLA 11.mdare updated.Test plan
csla.build.slnbuilds for all targets (netstandard2.0, net462 to net48, net10.0, net11.0).SafeDataReaderAsyncTestsrun against SQLite and pass on net10.0 and net11.0. They cover:CloseAsyncandDisposeAsync;DbDataReader.csla.test.slnsuite (TestCategory!=SkipOnCIServer) passes.Closes #4975
🤖 Generated with Claude Code