UMB.DataBaseOperations 3.0.0

dotnet add package UMB.DataBaseOperations --version 3.0.0
                    
NuGet\Install-Package UMB.DataBaseOperations -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UMB.DataBaseOperations" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UMB.DataBaseOperations" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="UMB.DataBaseOperations" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add UMB.DataBaseOperations --version 3.0.0
                    
#r "nuget: UMB.DataBaseOperations, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package UMB.DataBaseOperations@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=UMB.DataBaseOperations&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=UMB.DataBaseOperations&version=3.0.0
                    
Install as a Cake Tool

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

Documentation and examples

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 85 10/12/2026
2.1.2 421 7/3/2023
2.1.1 313 7/3/2023
2.1.0 321 7/3/2023
2.0.0 311 7/3/2023
1.4.1 477 12/22/2022
1.4.0 483 12/22/2022
1.3.0 589 7/28/2022
1.2.0 633 5/18/2022
1.0.2 635 3/23/2022
1.0.1 625 3/23/2022
1.0.0 625 3/23/2022