Allegro.Extensions.Dapper 1.2.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Allegro.Extensions.Dapper --version 1.2.0
NuGet\Install-Package Allegro.Extensions.Dapper -Version 1.2.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="Allegro.Extensions.Dapper" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Allegro.Extensions.Dapper --version 1.2.0
#r "nuget: Allegro.Extensions.Dapper, 1.2.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.
// Install Allegro.Extensions.Dapper as a Cake Addin
#addin nuget:?package=Allegro.Extensions.Dapper&version=1.2.0

// Install Allegro.Extensions.Dapper as a Cake Tool
#tool nuget:?package=Allegro.Extensions.Dapper&version=1.2.0

Allegro.Extensions.Dapper

This library contains useful utilities for simpler usage of Dapper library.

In this library you have generic implementation of DatabaseClient which is database agnostic.

You can use already created utilities for specific databases.

  • Allegro.Extensions.Dapper.Postgres

Then you will be able to use IDatabaseClient and perform SQL operations.

####If you want to use this library on it's own, please remember to implement IDatabaseConnectionFactory. Example implementation (for Postgres):

public class PostgresDatabaseConnectionFactory : IDatabaseConnectionFactory
{
    private readonly DatabaseConfiguration _databaseConfiguration;

    public PostgresDatabaseConnectionFactory(
        DatabaseConfiguration databaseConfiguration)
    {
        _databaseConfiguration = databaseConfiguration;
    }

    public DbConnection Create() =>
        new NpgsqlConnection(_databaseConfiguration.ConnectionString);
}

Configure this feature in Startup.cs:

services
    .AddDapperClient()
    .AddSingleton(new DatabaseConfiguration
    {
        ConnectionString = connectionString
    })
    .AddSingleton<IDatabaseConnectionFactory, PostgresDatabaseConnectionFactory>();

Allegro.Extensions.Dapper.Postgres

This library contains useful utilities for simpler usage for Postgres database with Dapper library.

Remember to configure this feature in Startup.cs:

services
    .AddDapperClient()
    .AddDapperPostgres(connectionString);

Then you will be able to use IDapperPostgresBinaryCopyClient and IDapperClient services and perform operations SQL queries against database.

Example usages:

public const string TableName = "TestTable";

//create table
await _dapperClient.ExecuteAsync($@"CREATE TABLE IF NOT EXISTS {TableName}
            (
                Id              SERIAL primary key,
                Username        VARCHAR(40) UNIQUE
            );
        ");

//drop table
await _dapperClient.ExecuteAsync($@"DROP TABLE IF EXISTS {TableName}");

//insert data into table with returning in transaction
await _dapperClient.ExecuteAndQueryInTransactionAsync<TestTable>($@"
            INSERT INTO {TableName}
            (
                Username
            )
            VALUES
            (
                @Username
            )
            RETURNING
                id AS Id,
                username AS Username;
        ");

//query records
await _dapperClient.QueryAsync<TestTable>($@"SELECT
            Id,
            Username
        FROM {TableName});
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 Allegro.Extensions.Dapper:

Package Downloads
Allegro.Extensions.Dapper.Postgres The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Postgres Dapper clients

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 651 10/26/2022
1.1.0 493 10/19/2022