Dapperling 1.0.0

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

// Install Dapperling as a Cake Tool
#tool nuget:?package=Dapperling&version=1.0.0                

Dapperling

NuGet License

A CRUD helper for Dapper for quickly selecting, inserting, updating or deleting data.

Provides syntax support for the following databases:

  • SQL Server
  • MySQL
  • PostgreSQL
  • SQLite
  • Firebase

Usage

Install the package from NuGet with dotnet add package Dapperling.

The below features are supported by Dapperling:

Method Description
Get Get an object by id
GetAll Get all objects of a specific type
Insert Insert an object or collection of objects
Update Update an object by id, or a collection of objects by their ids
Delete Delete an object by id, or a collection of objects by their ids
DeleteAll Delete all objects of a specific type

Querying and updating data

Use the below methods to quickly access data in your tables.

Get objects

Get an object by its id:

var article = connection.Get<Article>(1);

Get all objects of a specific type:

var articles = connection.GetAll<Article>();

Insert objects

Insert an object:

connection.Insert(new Article { Title = "Name" });

Insert a collection of objects:

connection.Insert(new[] { new Article { Title = "Name" } });

Update objects

Update an object by its id:

connection.Update(new Article { Id = 1, Title = "Name" });

Update a collection of objects by their ids:

connection.Update(new[] { new Article { Id = 1, Title = "Name" } });

Delete objects

Delete an object by its id:

connection.Delete(new Article { Id = 1 });

Delete a collection of objects by their ids:

connection.Delete(new[] { new Article { Id = 1 } });

Delete all objects of a specific type:

connection.DeleteAll<Article>();

Customizing queries

You can use several attributes to control the names of tables and columns, or control how the queries are generated.

[Table] attribute

Use the [Table] attribute to control the name of the table to use. By default, Dapperling pluralizes the name of your class as the table name, or in the case of Postgres, uses plural_snake_case as the table name.

[Table("articles")]
public class Article
{
    public int Id { get; set; }
}

[Column] attribute

Use the [Column] attribute to control the name of the column for each property. By default, the property name is used, or in the case of Postgres, uses snake_case.

public class Article
{
    public int Id { get; set; }

    [Column("column_name")]
    public string Name { get; set; }
}

[Key] attribute

Use the [Key] attribute to specify the identity column for your table. By default, a property named Id is used.

public class Article
{
    [Key]
    public int ArticleId { get; set; }

    public string Name { get; set; }
}

[ExplicitKey] attribute

If your primary key is not an identity column, use [ExplicitKey] to pass in the value instead of letting the database generate it.

public class Article
{
    [ExplicitKey]
    public Guid ArticleId { get; set; }

    public string Name { get; set; }
}

[Ignore] attribute

Use the [Ignore] attribute on properties to exclude them from insertion or updating.

public class Article
{
    public int Id { get; set; }

    [Ignore]
    public string Name { get; set; }
}

Extending Dapperling

By default, Dapplerling uses the lowercase name of the DbConnection used to determine the query syntax. To help Dapperling determine the type of connection you are using, you can use the below:

Dapperling.GetDatabaseType = connection => connection.GetType().Name;

You can also register new query syntax providers, as below:

Dapperling.RegisterAdapter("myconnection", new MyAdapter());

Dapperling.GetDatabaseType = connection => "myconnection";

If your connection type isn't recognised or you don't register an adapter, by default the SQL Server syntax is used.

Contributing

Please read CONTRIBUTING.md for details on how to contribute to this project.

Acknowledgements

Inspired by Dapper.Contrib and the excellent Dapper.SimpleCRUD ❤️

License

Inject is released under the MIT License

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework 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 tizen40 was computed.  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.
  • .NETStandard 2.0

  • net6.0

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.0 112 7/1/2024
1.1.0 116 6/13/2024
1.0.1 112 6/13/2024
1.0.0 216 2/23/2023
1.0.0-beta.2 100 2/23/2023
1.0.0-beta.1 92 2/23/2023