MicroOrm.Dapper.Repositories 1.8.3

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

// Install MicroOrm.Dapper.Repositories as a Cake Tool
#tool nuget:?package=MicroOrm.Dapper.Repositories&version=1.8.3

MyGet NuGet NuGet

codecov Codacy Badge GitHub contributors Build status License MIT

GitHub stars GitHub forks GitHub watchers

Description

If you like your code to run fast, you probably know about Micro ORMs. They are simple and one of their main goals is to be the fastest execution of your SQL sentences in you data repository. For some Micro ORM's you need to write your own SQL sentences and this is the case of the most popular Micro ORM Dapper

This tool abstracts the generation of the SQL sentence for CRUD operations based on each C# POCO class "metadata". We know there are plugins for both Micro ORMs that implement the execution of these tasks, but that's exactly where this tool is different. The "SQL Generator" is a generic component that generates all the CRUD sentences for a POCO class based on its definition and the possibility to override the SQL generatorand the way it builds each sentence.

The original idea was taken from Yoinbol.

I tested this with MSSQL, PostgreSQL and MySQL.

PM> Install-Package MicroOrm.Dapper.Repositories

Metadata attributes

[Key]
From System.ComponentModel.DataAnnotations - Use for primary key.

[Identity]
Use for identity key.

[Table]
From System.ComponentModel.DataAnnotations.Schema - By default the database table name will match the model name but it can be overridden with this.

[Column]
From System.ComponentModel.DataAnnotations.Schema - By default the column name will match the property name but it can be overridden with this.

[NotMapped]
From System.ComponentModel.DataAnnotations.Schema - For "logical" properties that do not have a corresponding column and have to be ignored by the SQL Generator.

[Deleted], [Status]
For tables that implement "logical deletes" instead of physical deletes. Use this to decorate the bool or enum.

[LeftJoin]

[InnerJoin]

[RightJoin]

[UpdatedAt]

Notes
  • By default the SQL Generator is going to map the POCO name with the table name, and each public property to a column.
  • If the [Deleted] is used on a certain POCO, the sentence will be an update instead of a delete.
  • Supports complex primary keys.
  • Supports simple Joins.

Examples

"Users" POCO:

[Table("Users")]
public class User
{
    [Key, Identity]
    public int Id { get; set; }

    public string ReadOnly => "test"; // because don't have set

    public string Name { get; set; }

    public int AddressId { get; set; }

    [LeftJoin("Cars", "Id", "UserId")]
    public List<Car> Cars { get; set; }

    [LeftJoin("Addresses", "AddressId", "Id")]
    public Address Address { get; set; }

    [Status, Deleted]
    public bool Deleted { get; set; }

    [UpdatedAt]
    public DateTime? UpdatedAt { get; set; }
}

"Cars" POCO:

[Table("Cars")]
public class Car
{
    [Key, Identity]
    public int Id { get; set; }

    public string Name { get; set; }

    public byte[] Data { get; set; }

    public int UserId { get; set; }

    [LeftJoin("Users", "UserId", "Id")]
    public User User { get; set; }

    [Status]
    public StatusCar Status { get; set; }
}

public enum StatusCar
{
    Inactive = 0,

    Active = 1,

    [Deleted]
    Deleted = -1
}

Implements the repository:

public class UserRepository : DapperRepository<User>
{

    public UserRepository(IDbConnection connection, ISqlGenerator<User> sqlGenerator)
        : base(connection, sqlGenerator)
    {


    }
}

Query:

var user = await userRepository.FindAsync(x => x.Id == 5);

var allUsers = await userRepository.FindAllAsync(x => x.AccountId == 3 && x.Deleted != false); // all users for account id 3 and not deleted
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 was computed.  netstandard2.1 was computed. 
.NET Framework net45 is compatible.  net451 was computed.  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 (5)

Showing the top 5 NuGet packages that depend on MicroOrm.Dapper.Repositories:

Package Downloads
Crystal.Dapper

This package contains the classes and methods to work with Dapper

GbLib.DapperOrm

DapperOrm

GbLib.Repositories

Package Description

GbLib.Entities

Package Description

GenericCRUD

Don't repeat yourself! GenericCrud is a highly flexible library that provides your API with a skeleton for CRUD controllers without using EF. You can configure model validation, user permission validation etc.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.26.0 14,995 12/21/2023
1.25.1 100,548 7/3/2023
1.25.0 72,545 2/26/2023
1.24.2 6,395 1/31/2023
1.24.1 72,426 1/4/2023
1.24.0 2,253 11/21/2022
1.23.2 18,350 10/16/2022
1.23.1 13,653 9/8/2022
1.23.0 15,682 7/14/2022
1.22.0 25,126 5/1/2022
1.21.0 23,854 2/9/2022
1.20.1 1,058 2/9/2022
1.20.0 2,957 1/29/2022
1.19.1 21,640 9/19/2021
1.19.0 8,652 8/26/2021
1.18.1 101,387 6/24/2021
1.18.0 10,634 5/21/2021
1.17.0 9,384 4/29/2021
1.16.2 27,723 3/29/2021
1.16.1 5,815 3/12/2021
1.16.0 32,885 2/18/2021
1.15.0 56,967 8/28/2020
1.14.1 111,387 3/1/2020
1.14.0 1,230 2/27/2020
1.13.0 1,508 2/18/2020
1.12.0 26,751 1/11/2020
1.11.0 26,552 11/14/2019
1.11.0-beta1 2,222 10/4/2019
1.10.0-beta3 13,572 4/26/2019
1.10.0-beta2 1,116 4/10/2019
1.10.0-beta1 16,516 8/25/2018
1.8.3 128,455 10/26/2017
1.8.2 2,800 9/16/2017
1.8.1 2,690 8/20/2017
1.8.0 2,035 7/18/2017
1.7.3 2,745 5/30/2017
1.7.2 1,714 5/25/2017
1.7.1 3,345 5/9/2017
1.7.0 1,923 5/8/2017
1.6.6 2,124 4/21/2017
1.6.5 1,715 4/19/2017
1.6.4 1,720 4/16/2017
1.6.3 1,818 4/5/2017
1.6.2 5,488 3/28/2017
1.6.1 9,654 3/14/2017
1.6.0 6,620 3/6/2017
1.6.0-beta5 1,630 2/18/2017
1.6.0-beta4 1,887 12/15/2016
1.6.0-beta3 1,443 12/14/2016
1.6.0-beta2 1,445 12/2/2016
1.6.0-beta1 1,443 12/1/2016
1.5.0 6,244 8/18/2016
1.4.2 4,565 7/20/2016
1.4.1 1,695 7/19/2016
1.4.0 1,945 7/11/2016
1.4.0-beta3 1,483 7/7/2016
1.4.0-beta1 2,058 2/23/2016
1.3.3 2,251 11/3/2015
1.3.2 1,748 10/22/2015
1.3.1 1,681 10/13/2015
1.2.3 1,859 9/25/2015
1.2.1 2,116 9/9/2015
1.2.0 2,080 8/31/2015
1.0.1 2,118 7/24/2015
1.0.0 2,105 7/7/2015