ByteTerrace.Ouroboros.Database.SqlClient 1.0.0-preview0

Prefix Reserved
This is a prerelease version of ByteTerrace.Ouroboros.Database.SqlClient.
dotnet add package ByteTerrace.Ouroboros.Database.SqlClient --version 1.0.0-preview0
                    
NuGet\Install-Package ByteTerrace.Ouroboros.Database.SqlClient -Version 1.0.0-preview0
                    
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.SqlClient" Version="1.0.0-preview0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ByteTerrace.Ouroboros.Database.SqlClient" Version="1.0.0-preview0" />
                    
Directory.Packages.props
<PackageReference Include="ByteTerrace.Ouroboros.Database.SqlClient" />
                    
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 ByteTerrace.Ouroboros.Database.SqlClient --version 1.0.0-preview0
                    
#r "nuget: ByteTerrace.Ouroboros.Database.SqlClient, 1.0.0-preview0"
                    
#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.
#addin nuget:?package=ByteTerrace.Ouroboros.Database.SqlClient&version=1.0.0-preview0&prerelease
                    
Install ByteTerrace.Ouroboros.Database.SqlClient as a Cake Addin
#tool nuget:?package=ByteTerrace.Ouroboros.Database.SqlClient&version=1.0.0-preview0&prerelease
                    
Install ByteTerrace.Ouroboros.Database.SqlClient as a Cake Tool

Basic Usage

using ByteTerrace.Ouroboros.Database.SqlClient;
using Microsoft.Data.SqlClient;

var options = MsSqlClientOptions.New(
    connectionString: "Server=(localdb)\\MSSQLLocalDb;Initial Catalog=master;",
    providerFactory: SqlClientFactory.Instance
);
var client = MsSqlClient.New(options: options);

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

ASP.NET Core 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.SqlClient;

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

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

ExampleController.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<MsSqlClient> DbClientFactory { get; }

        public ExampleController(IDbClientFactory<MsSqlClient> 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 net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.SqlClient:

Package Downloads
ByteTerrace.Ouroboros.Core

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-preview0 634 3/3/2022

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