ByteTerrace.Ouroboros.Database 1.0.0-preview6

Prefix Reserved
Additional Details

Changed framework version support from net6.0 to netstandard2.1.

This is a prerelease version of ByteTerrace.Ouroboros.Database.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package ByteTerrace.Ouroboros.Database --version 1.0.0-preview6                
NuGet\Install-Package ByteTerrace.Ouroboros.Database -Version 1.0.0-preview6                
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="ByteTerrace.Ouroboros.Database" Version="1.0.0-preview6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ByteTerrace.Ouroboros.Database --version 1.0.0-preview6                
#r "nuget: ByteTerrace.Ouroboros.Database, 1.0.0-preview6"                
#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.
// Install ByteTerrace.Ouroboros.Database as a Cake Addin
#addin nuget:?package=ByteTerrace.Ouroboros.Database&version=1.0.0-preview6&prerelease

// Install ByteTerrace.Ouroboros.Database as a Cake Tool
#tool nuget:?package=ByteTerrace.Ouroboros.Database&version=1.0.0-preview6&prerelease                

Basic Usage

var options = DbClientOptions.New(
    connectionString: "Server=(localdb)\\MSSQLLocalDb;Initial Catalog=master;",
    providerFactory: SqlClientFactory.Instance // Depends on Microsoft.Data.SqlClient package.
);
var client = DbClient.New(options: options);

_ = client
    .ToIDbClient()
    .ExecuteStoredProcedure(
        name: "sp_tables",
        schemaName: "dbo"
    );

ASP.NET Core (Version 6) Integration

appsettings.json (or equivalent)

{
    "ConnectionStrings": {
        "LocalDb": {
            "type": "Microsoft.Data.SqlClient.SqlClientFactory, Microsoft.Data.SqlClient, Version=4.1.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5",
            "value": "Server=(localdb)\\MSSQLLocalDb;Initial Catalog=master;"
        }
    },
    "Logging": {
        "LogLevel": {
            "ByteTerrace.Ouroboros.Database": "None" // Set to Trace for debugging output.
        }
    }
}

Program.cs

using ByteTerrace.Ouroboros.Database;

var builder = WebApplication.CreateBuilder(arges: args);

builder
    .Services
    .AddDbClients(configuration: builder.Configuration);

ValuesController.cs

using ByteTerrace.Ouroboros.Database;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace MyNamespace
{
    [Route("api/[controller]")]
    [ApiController]
    public class ExampleController : ControllerBase
    {
        public IDbClientFactory DbClientFactory { get; }

        public ExampleController(IDbClientFactory dbClientFactory) {
            DbClientFactory = dbClientFactory;
        }

        [AllowAnonymous]
        [HttpGet]
        [Route("test-db-connection")]
        public async ValueTask<IActionResult> TestDbConnection(CancellationToken cancellationToken) {
            using var client = DbClientFactory.NewClient(name: "MyConnection");

            await client.OpenConnectionAsync(cancellationToken: cancellationToken);

            return Ok();
        }
    }
}

NuGet References

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

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ByteTerrace.Ouroboros.Database:

Package Downloads
ByteTerrace.Ouroboros.Database.SqlClient

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-preview13 559 3/1/2022

This is a preview that is not intented for production use.