Rocket.Libraries.DatabaseIntegrator 1.8.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Rocket.Libraries.DatabaseIntegrator --version 1.8.0
                    
NuGet\Install-Package Rocket.Libraries.DatabaseIntegrator -Version 1.8.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="Rocket.Libraries.DatabaseIntegrator" Version="1.8.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rocket.Libraries.DatabaseIntegrator" Version="1.8.0" />
                    
Directory.Packages.props
<PackageReference Include="Rocket.Libraries.DatabaseIntegrator" />
                    
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 Rocket.Libraries.DatabaseIntegrator --version 1.8.0
                    
#r "nuget: Rocket.Libraries.DatabaseIntegrator, 1.8.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 Rocket.Libraries.DatabaseIntegrator@1.8.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=Rocket.Libraries.DatabaseIntegrator&version=1.8.0
                    
Install as a Cake Addin
#tool nuget:?package=Rocket.Libraries.DatabaseIntegrator&version=1.8.0
                    
Install as a Cake Tool

Rocket.Libraries.DatabaseIntegrator

This library is a layer on top of Dapper ORM and makes its goal is making working with your database more structured and even easier.

Think of it like a framework for Dapper ORM, this way every one on your team writes code in a predictable and hence easy to understand manner.

It has extensively been tested with MS SQL and MySQL/MariaDB and even used in multiple production environments.

Installing

The library is available on nuget and can be installed using

    dotnet add package Rocket.Libraries.DatabaseIntegrator

Usage

This library is meant to use dotnet's default dependancy injection.

Configuration

  1. Let's tell the library how to connect to your database

In your appsettings.json, add the following:

{
     //.... Your other settings

    "DatabaseConnectionSettings": {
        "ConnectionString": "Server=localhost;Database=database_name;Uid=sam;Pwd=the-password;charset=utf8;convertzerodatetime=true;"
  }
}
  1. Read the connection string during runtime.

Create a class to read the connection string and return a connection to the database.


using System.Data;
using Microsoft.Extensions.Options;
using MySqlConnector;
using Rocket.Libraries.DatabaseIntegrator;

namespace App.Database
{
    public class DatabaseConnectionProvider : IConnectionProvider
    {
        private readonly string connectionString;

        public DatabaseConnectionProvider(
            IOptions<DatabaseConnectionSettings> databaseOptions)
        {

            connectionString = databaseOptions.Value.ConnectionString;
        }

        public IDbConnection Get(string connectionString)
        {
            var connection = new MySqlConnection(connectionString);

            return connection;
        }
    }
}


Please note the using Rocket.Libraries.DatabaseIntegrator; included in the class. It gives you access to the the interface IConnectionProvider and to the object DatabaseConnectionSettings which maps onto the connection string settings we created in appsettings.json

  1. Let's configure our app to read the settings. In Program.cs at the top of the file add
    using Rocket.Libraries.DatabaseIntegrator;

Then in your services configuration, add the following lines

    builder.Services.Configure<DatabaseConnectionSettings>(builder.Configuration.GetSection("DatabaseConnectionSettings"));
    builder.Services.InitializeDatabaseIntegrator<long,DatabaseConnectionProvider>();

In builder.Services.InitializeDatabaseIntegrator<long,DatabaseConnectionProvider>(); the first generic parameter is the type that your database primary keys are, while the second is the database connection provider class we created in the previous step.

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. 
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
1.8.3 451 12/27/2023
1.8.2 207 12/27/2023
1.8.0 210 12/27/2023
1.8.0-beta02 133 12/27/2023
1.8.0-beta01 192 11/30/2023
1.7.0-beta01 274 5/28/2023
1.6.1 754 3/25/2022
1.6.0 555 3/25/2022
1.5.1 566 3/24/2022
1.5.0 565 3/24/2022
1.4.6 540 6/22/2021
1.4.5 499 6/22/2021
1.4.4 495 6/22/2021
1.4.3 496 6/22/2021
1.4.2 463 6/22/2021
1.4.1 300 6/22/2021
1.3.1 435 8/19/2020
1.3.0 427 7/30/2020
1.2.2 428 7/30/2020
1.2.2-beta01 380 7/1/2020
1.2.1 398 7/1/2020
1.2.1-beta06 386 6/8/2020
1.2.1-beta05 370 6/8/2020
1.2.1-beta04 378 6/8/2020
1.2.1-beta03 377 6/5/2020
1.2.1-beta02 373 6/5/2020
1.2.1-beta01 408 6/4/2020
1.2.0-beta01 412 6/4/2020
1.1.0-beta01 401 6/3/2020
1.0.0-beta13 386 5/15/2020
1.0.0-beta12 363 5/15/2020
1.0.0-beta11 372 5/15/2020
1.0.0-beta10 364 5/14/2020
1.0.0-beta09 365 5/14/2020
1.0.0-beta08 362 5/14/2020
1.0.0-beta07 368 5/14/2020
1.0.0-beta06 365 5/13/2020
1.0.0-beta05 375 5/13/2020