UMB.DataBaseOperations
3.0.0
dotnet add package UMB.DataBaseOperations --version 3.0.0
NuGet\Install-Package UMB.DataBaseOperations -Version 3.0.0
<PackageReference Include="UMB.DataBaseOperations" Version="3.0.0" />
<PackageVersion Include="UMB.DataBaseOperations" Version="3.0.0" />
<PackageReference Include="UMB.DataBaseOperations" />
paket add UMB.DataBaseOperations --version 3.0.0
#r "nuget: UMB.DataBaseOperations, 3.0.0"
#:package UMB.DataBaseOperations@3.0.0
#addin nuget:?package=UMB.DataBaseOperations&version=3.0.0
#tool nuget:?package=UMB.DataBaseOperations&version=3.0.0
UMB.DataBaseOperations
It is a package that allows you to perform an operation on a SQL database using stores procedures or a direct query
Authors
Documentation
Architecture
The package now includes an abstraction layer (ISqlCommandExecutor) that enables dependency injection and testing without requiring a live SQL Server connection.
Core Components
- IDataBaseOperations: Public interface for database operations (SetConnectionString, SpExecution, SpExecutionAsync, QueryExecution).
- DataBaseOperations: Implementation that delegates SQL execution to an injected
ISqlCommandExecutor. - ISqlCommandExecutor: Internal abstraction for Execute/ExecuteAsync methods; enables mocking in unit tests.
- SqlCommandExecutor: Default implementation using System.Data.SqlClient.
- DataBaseResponse: Result wrapper with error tracking, execution duration, row/table counts, and optional DataSet.
Design Patterns
- Dependency Injection: Constructors accept optional logger and command executor.
- Result Pattern: Operations return DataBaseResponse wrapping success/failure; CancellationToken propagates to async methods.
- Logging: Operations log errors and warnings via ILogger<T> when available (optional).
Testing
The DataBaseOperationsNUnitTests project contains 22+ unit tests (NUnit 4.3.2) using Moq to mock ISqlCommandExecutor. Tests cover:
- Input validation (null, whitespace connection string, procedure, query).
- Success scenarios (single/multiple tables, multiple rows).
- Error scenarios (executor exceptions, cancellation propagation).
- Edge cases (empty results, tables without rows).
All tests execute without requiring SQL Server. Tests run on net10.0, ensuring modern async/await compatibility.
Notes
- Targets: net6.0 and net48. The library keeps System.Data.SqlClient for compatibility with .NET Framework 4.8. Consider migrating to Microsoft.Data.SqlClient for .NET 6 in a separate PR (see PROPOSAL_MIGRATE_TO_MICROSOFT_DATA_SQLCLIENT.md).
- Usage: Call SetConnectionString before any operation.
- DeriveParameters: The library attempts to call SqlCommandBuilder.DeriveParameters; this requires appropriate permissions. If it fails, the operation continues and provided parameters are applied. Prefer passing explicit parameters when possible.
- Async behavior: SpExecutionAsync uses ExecuteReaderAsync but still loads results synchronously into a DataTable to populate the DataSet. For high-throughput scenarios consider mapping from DbDataReader directly to DTOs instead of DataSet.
- Testing Strategy: Use constructor overloads to inject mocks; do not instantiate ISqlCommandExecutor constructors directly in production code.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
- System.Data.SqlClient (>= 4.8.3)
- System.Net.Http (>= 4.3.4)
-
net6.0
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
- System.Data.SqlClient (>= 4.8.3)
- System.Net.Http (>= 4.3.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.