You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c44912a
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+72-36Lines changed: 72 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,58 +1,98 @@
1
1
# NuExt.System.Data
2
2
3
-
`NuExt.System.Data`provides a lightweight and extensible foundation for data access in .NET applications. It combines practical ADO.NET extensions, reusable DAL and database context abstractions, explicit transaction management, and provider-independent database migrations with validated history tracking.
3
+
`NuExt.System.Data`is a **lightweight, provider-independent data access foundation for .NET applications and application frameworks**, combining practical ADO.NET extensions, explicit database context ownership, reusable DAL abstractions, and deterministic database migration orchestration.
-**ADO.NET Extensions**: Provides helpers for reading, converting, and manipulating data through `DataReader`, `DataRow`, and `DataTable`.
14
-
-**DAL Infrastructure**: Includes lightweight base classes and database context abstractions for implementing data access layers.
15
-
-**Database Migrations**: Provides provider-independent orchestration with ordered execution, sequence-aware history validation, optional version metadata, cancellation support, and provider-specific execution contexts.
13
+
-**Provider-independent** — common DAL and migration contracts remain separate from provider-specific connections, transactions, and history storage
14
+
-**Ownership-aware** — DAL operations explicitly distinguish owned contexts from caller-provided contexts
15
+
-**Composable** — independent operations and larger transactional units of work use the same DAL implementation
16
+
-**Migration-safe** — configured migrations and applied history are validated as one ordered sequence before pending changes run
17
+
-**ADO.NET-focused** — typed reader, row, and table helpers without an ORM or tracking model
18
+
-**Consistent across runtimes** — a stable API surface across modern .NET, .NET Standard, and .NET Framework
19
+
-**Dependency-light** — no required ORM, hosting model, dependency injection container, or database provider
16
20
17
-
## DAL Context Ownership
21
+
## Designed for
22
+
23
+
NuExt.System.Data is intended for application and framework authors who need:
24
+
25
+
- a small reusable foundation above ADO.NET rather than a full ORM;
26
+
- explicit ownership and transaction boundaries in data access code;
27
+
- the same DAL methods for standalone operations and caller-controlled units of work;
28
+
- deterministic migration orchestration with provider-specific execution;
29
+
- strict validation of migration ordering and applied history;
30
+
- compatibility across modern .NET and legacy .NET Framework targets.
31
+
32
+
## Core infrastructure
33
+
34
+
### ADO.NET extensions
35
+
36
+
-`DataReaderExtensions` adds name-based typed accessors and nullable getters for older targets.
37
+
-`DataRowExtensions` provides typed and nullable conversions by index, name, `DataColumn`, or `DataRowVersion`.
38
+
-`DataTableExtensions` provides focused table operations without object tracking.
39
+
- Compatibility implementations resolve column names to ordinals and preserve provider behavior.
40
+
41
+
### DAL and database contexts
42
+
43
+
-`IDbContext` defines the lifetime contract for provider-specific database contexts.
44
+
-`IDbContextExecutor<TDbContext>` creates and executes owned context scopes while also supporting operations over existing contexts.
45
+
-`DalBase<TDbContext>` centralizes DAL execution and exposes the same synchronous and asynchronous operation model for owned and borrowed contexts.
46
+
-`DbContextExtensions` adds focused helpers around context execution without hiding ownership boundaries.
47
+
48
+
### Explicit context ownership
18
49
19
50
The DAL infrastructure supports two execution models:
20
51
21
-
-**Owned context**: When no database context is provided, the provider-specific executor creates and owns the context. It manages the connection, transaction, commit or rollback, and resource cleanup.
22
-
-**Borrowed context**: When an existing database context is provided, the DAL participates in the caller's unit of work without committing, rolling back, or disposing the context.
52
+
-**Owned context** — when no context is supplied, the provider-specific executor creates and owns the context, including connection lifetime, transaction completion, and cleanup.
53
+
-**Borrowed context** — when an existing context is supplied, the DAL participates in the caller's unit of work without committing, rolling back, or disposing that context.
23
54
24
-
This allows individual DAL operations to run independently while also supporting coordinated operations across multiple DAL components within the same transaction.
55
+
This design allows a DAL operation to run independently or compose with other operations inside one caller-controlled transaction without duplicating data access logic.
25
56
26
-
##Database Migration Model
57
+
### Deterministic database migrations
27
58
28
-
The migration framework is designed for application-integrated, forward-only database evolution. Migrations are registered explicitly in the order in which they must be applied, making the target schema deterministic and avoiding reflection-based discovery.
59
+
Migration orchestration is provider-independent; transaction handling and history persistence are provider-specific.
29
60
30
-
Each applied migration is recorded with its one-based position in the configured migration sequence, stable identifier, application time, and optional version information. Before applying pending migrations, the framework validates that the stored history is an exact prefix of the configured sequence, including both sequence positions and migration identifiers. This detects removed, renamed, reordered, unknown, or incorrectly positioned migrations before any schema changes are made.
61
+
-`DbMigration<TContext>` represents an ordered schema or data change with a stable identifier.
62
+
-`DbMigrationContext` carries cancellation and provides a base for provider-specific state.
63
+
-`DbMigrator<TContext>` validates migration configuration and history before applying pending migrations.
64
+
-`IDbMigrationExecutor<TContext>` defines the provider-specific execution and transaction boundary.
65
+
-`IDbMigrationHistory<TContext>` defines migration history storage.
66
+
-`AppliedDbMigration` records the sequence, identifier, UTC application time, and optional version.
31
67
32
-
Transaction ownership is explicit and provider-controlled. A provider can execute the complete migration batch within its own transaction or participate in an existing database context, allowing migrations and application operations to share the same transaction.
68
+
Before executing pending migrations, the migrator verifies that:
33
69
34
-
Migration history storage is provider-defined. Providers may maintain a single history or isolate multiple independently validated migration sequences while reusing the same orchestration model.
70
+
- configured migration identifiers are non-empty and unique;
71
+
- applied history does not contain more entries than the current configuration;
72
+
- applied sequence numbers are contiguous and one-based;
73
+
- every applied identifier matches the configured migration at the same position.
35
74
36
-
## Commonly Used Types
75
+
This treats migration history as a strict prefix of the configured migration sequence and prevents silently continuing from reordered, removed, duplicated, or otherwise inconsistent migrations.
37
76
38
-
-**`DalBase<TDbContext>`**: Base class for DAL implementations that supports borrowed contexts and provider-managed owned context scopes.
39
-
-**`DataReaderExtensions`**: Provides extension methods for data reader operations.
40
-
-**`DataRowExtensions`**: Provides extension methods for data row operations.
41
-
-**`DataTableExtensions`**: Provides extension methods for data table operations.
42
-
-**`IDbContext`**: Defines transaction state and lifecycle operations for database contexts.
43
-
-**`IDbContextExecutor<TDbContext>`**: Defines provider-specific ownership and execution of database context scopes.
44
-
-**`AppliedDbMigration`**: Represents an applied migration together with its sequence position, identifier, application time, and optional version information.
45
-
-**`DbMigration<TContext>`**: Base class for defining ordered database schema and data migrations.
46
-
-**`DbMigrationContext`**: Base class for provider-specific migration execution contexts.
47
-
-**`DbMigrator<TContext>`**: Validates migration configuration and applied history, and executes pending migrations.
48
-
-**`IDbMigrationExecutor<TContext>`**: Defines provider-specific migration execution and transaction handling.
49
-
-**`IDbMigrationHistory<TContext>`**: Defines provider-specific storage operations for applied migration history.
77
+
### Cancellation and transaction boundaries
78
+
79
+
- Cancellation is checked before execution and before each pending migration.
80
+
- The migration context passes the cancellation token to provider code and migrations.
81
+
- A migration is recorded only after its `Up` operation completes successfully.
82
+
-`IDbMigrationExecutor<TContext>` controls transactions and keeps migration history consistent.
83
+
84
+
## Compatibility
85
+
86
+
-**.NET Standard 2.0+, .NET 8/9/10, and .NET Framework 4.6.2+**
87
+
- Works with provider-specific implementations built on ADO.NET
88
+
- Includes selected ADO.NET API backports for older targets
89
+
- Does not require Entity Framework or another ORM
50
90
51
91
## Installation
52
92
53
93
Via [NuGet](https://www.nuget.org/):
54
94
55
-
```sh
95
+
```shell
56
96
dotnet add package NuExt.System.Data
57
97
```
58
98
@@ -62,25 +102,21 @@ Or via Visual Studio:
62
102
2. Search for `NuExt.System.Data`.
63
103
3. Click "Install".
64
104
65
-
## Compatibility
66
-
67
-
**.NET Standard 2.0+, .NET 8/9/10 and .NET Framework 4.6.2+**
68
-
69
-
## Usage Examples
105
+
## Provider implementation
70
106
71
-
For a complete provider implementation and migration example, see:
107
+
For a complete provider implementation, transaction strategy, migration history store, and usage example, see:
<Description>High-level data access utilities for .NET, providing extensions for DataReader, DataRow, and DataTable, lightweight DAL and database context abstractions, and a provider-independent migration framework with ordered execution and validated history tracking.</Description>
7
+
<Description>Lightweight, provider-independent data access foundation for .NET, providing ADO.NET extensions for DataReader, DataRow, and DataTable, reusable DAL and database context abstractions, and deterministic database migrations with ordered execution and validated history tracking.</Description>
0 commit comments