Dommel.Pag 1.2.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package Dommel.Pag --version 1.2.6
NuGet\Install-Package Dommel.Pag -Version 1.2.6
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="Dommel.Pag" Version="1.2.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dommel.Pag --version 1.2.6
#r "nuget: Dommel.Pag, 1.2.6"
#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 Dommel.Pag as a Cake Addin
#addin nuget:?package=Dommel.Pag&version=1.2.6

// Install Dommel.Pag as a Cake Tool
#tool nuget:?package=Dommel.Pag&version=1.2.6

Fork

Added column resolvers to work on Select/Get methods

Added paging support for Select/SelectAsync and Count/CountAsync and NO SYNC

Added support to provide the Primary Key value on Create with DatabaseGeneratedAttribute (DatabaseGeneratedOption.None) on Key mapping for Entities.

Added support for logs/audit with methods that return the executed query and its params.

Dommel

Simple CRUD operations for Dapper.

Windows Linux
Build status Build Status

<hr>

Dommel provides a convenient API for CRUD operations using extension methods on the IDbConnection interface. The SQL queries are generated based on your POCO entities. Dommel also supports LINQ expressions which are being translated to SQL expressions. Dapper is used for query execution and object mapping.

Dommel also provides extensibility points to change the bahavior of resolving table names, column names, the key property and POCO properties. See Extensibility for more details.

<hr>

Download

Download Dommel on NuGet

<hr>

API

Retrieving entities by id
using (var con = new SqlConnection())
{
   var product = con.Get<Product>(1);
}
Retrieving all entities in a table
using (var con = new SqlConnection())
{
   var products = con.GetAll<Product>().ToList();
}
Selecting entities using a predicate

Dommel allows you to specify a predicate which is being translated into a SQL expression. The arguments in the lambda expression are added as parameters to the command.

using (var con = new SqlConnection())
{
   var products = con.Select<Product>(p => p.Name == "Awesome bike");
   
   var products = con.Select<Product>(p => p.Created < new DateTime(2014, 12, 31) && p.InStock > 5);
}
Inserting entities
using (var con = new SqlConnection())
{
   var product = new Product { Name = "Awesome bike", InStock = 4 };
   int id = con.Insert(product);
}
Updating entities
using (var con = new SqlConnection())
{
   var product = con.Get<Product>(1);
   product.LastUpdate = DateTime.Now;
   con.Update(product);
}
Removing entities
using (var con = new SqlConnection())
{
   var product = con.Get<Product>(1);
   con.Delete(product);
}

<hr>

Query builders

Dommel supports building specialized queries for a certain RDBMS. By default, query builders for the following RDMBS are included: SQL Server, SQL Server CE, SQLite, MySQL and Postgres. The query builder to be used is determined by the connection type. To add or overwrite an existing query builder, use the AddSqlBuilder() method:

DommelMapper.AddSqlBuilder(typeof(SqlConnection), new CustomSqlBuilder());

<hr>

Extensibility

ITableNameResolver

Implement this interface if you want to customize the resolving of table names when building SQL queries.

public class CustomTableNameResolver : DommelMapper.ITableNameResolver
{
    public string ResolveTableName(Type type)
    {
        // Every table has prefix 'tbl'.
        return $"tbl{type.Name}";
    }
}

Use the SetTableNameResolver() method to register the custom implementation:

DommelMapper.SetTableNameResolver(new CustomTableNameResolver());
IKeyPropertyResolver

Implement this interface if you want to customize the resolving of the key property of an entity. By default, Dommel will search for a property with the [Key] attribute, or a column with the name 'Id'.

If you, for example, have the naming convention of {TypeName}Id for key properties, you would implement the IKeyPropertyResolver like this:

public class CustomKeyPropertyResolver : DommelMapper.IKeyPropertyResolver
{
    public PropertyInfo ResolveKeyProperty(Type type)
    {
        return type.GetProperties().Single(p => p.Name == $"{type.Name}Id");
    }
}

Use the SetKeyPropertyResolver() method to register the custom implementation:

DommelMapper.SetKeyPropertyResolver(new CustomKeyPropertyResolver());
IColumnNameResolver

Implement this interface if you want to customize the resolving of column names for when building SQL queries. This is useful when your naming conventions for database columns are different than your POCO properties.

public class CustomColumnNameResolver : DommelMapper.IColumnNameResolver
{
    public string ResolveColumnName(PropertyInfo propertyInfo)
    {
        // Every column has prefix 'fld' and is uppercase.
        return $"fld{propertyInfo.Name.ToUpper()}";
    }
}

Use the SetColumnNameResolver() method to register the custom implementation:

DommelMapper.SetColumnNameResolver(new CustomColumnNameResolver());

The Dapper.FluentMap.Dommel extension implements these interfaces using the configured mapping. Also see: Dapper.FluentMap.

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. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net451 is compatible.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 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

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.2.10 12,745 1/24/2019
1.2.9 2,942 8/8/2018
1.2.8 922 8/2/2018
1.2.7 764 8/1/2018
1.2.6 793 8/1/2018
1.2.5 780 8/1/2018
1.2.4 1,244 5/2/2018
1.2.3 1,680 4/19/2018
1.2.2 1,169 3/20/2018
1.2.1 929 3/19/2018
1.2.0 842 3/19/2018
1.1.0 895 3/19/2018
1.0.0 794 3/15/2018