Z.Dapper.Plus
7.5.4
Prefix Reserved
See the version list below for details.
dotnet add package Z.Dapper.Plus --version 7.5.4
NuGet\Install-Package Z.Dapper.Plus -Version 7.5.4
<PackageReference Include="Z.Dapper.Plus" Version="7.5.4" />
paket add Z.Dapper.Plus --version 7.5.4
#r "nuget: Z.Dapper.Plus, 7.5.4"
// Install Z.Dapper.Plus as a Cake Addin #addin nuget:?package=Z.Dapper.Plus&version=7.5.4 // Install Z.Dapper.Plus as a Cake Tool #tool nuget:?package=Z.Dapper.Plus&version=7.5.4
Dapper Plus
Dapper Plus is a high-performance NuGet package providing essential extensions for Dapper, a popular micro-ORM for .NET. It is specifically designed to simplify and enhance CRUD (Create, Read, Update, Delete) operations in .NET applications.
The Dapper Plus library offers a variety of features for bulk operations, including BulkInsert
, BulkDelete
, BulkUpdate
, and BulkMerge
— features that are not provided by Dapper by default.
The primary advantages of using Dapper Plus include improved efficiency and speed in managing large volumes of data in .NET applications. Dapper Plus makes your applications faster, simpler to write, and easier to maintain, while preserving the versatility and performance benefits of Dapper.
Resources:
- Official Website: For comprehensive information, updates, tutorials, and more, visit our official website. Learn how Dapper Plus can transform your application's data layer.
- Contact Us: If you have any questions or require assistance, don't hesitate to reach out. We're here to help you maximize the benefits of Dapper Plus.
- GitHub Issues: If you encounter an issue or have a feature request, let us know on GitHub. Your feedback is invaluable to us in improving Dapper Plus.
Supported .NET Versions
Dapper Plus is designed to work with a broad spectrum of .NET versions, including .NET Framework 4.0 and onwards, as well as .NET Standard 2.0 and beyond. Additionally, it is compatible with the most recent .NET versions.
We always recommand to use the latest version of Dapper Plus package. This ensures that your application benefits from the latest advancements in performance, security, and features provided by Dapper Plus.
Main Features
Dapper Plus provides a robust suite of bulk operations that can enhance performance when managing data. These features aim to handle thousands of entities with ease:
- BulkInsert: This is the fastest method for inserting thousands of entities in your database, saving you valuable processing time.
- BulkUpdate: This feature allows for rapid updates to thousands of entities, thereby maintaining data consistency and accuracy with impressive speed.
- BulkDelete: This allows for the swift removal of thousands of entities, ensuring efficient data management.
- BulkMerge (BulkUpsert): This feature combines insert and update operations into a single efficient transaction, making data management more streamlined.
For a more detailed explanation and examples of each operation, please visit our documentation page. It offers a wealth of information and practical examples to help you utilize Dapper Plus to its full potential.
Getting Started
One of the major advantages of Dapper Plus is its simplicity and ease of use, particularly for those already comfortable with Dapper. Suppose you need to insert thousands of customers into your database. In that case, a single line of code is all it takes:
connection.BulkInsert(customers);
This line of code utilizes the BulkInsert
method that extends your IDbConnection
, empowering you with the capability to perform bulk operations with ease.
Moreover, if your task involves inserting only the customers who do not already exist in your database, you can accomplish this using the InsertIfNotExists
option:
connection.UseBulkOptions(options => { options.InsertIfNotExists = true;})
.BulkInsert(customers);
With this approach, the operation becomes not only efficient but also intelligent, assisting you in maintaining the integrity of your data.
To explore various use-cases with the library, visit our collection of online examples:
These examples are designed to provide a practical understanding of Dapper Plus, showcasing its powerful features and flexible options in different scenarios. Use these to familiarize yourself with Dapper Plus and unlock its full potential in your applications.
Advanced Usage
Single Action
Methods prefixed with Single
are included for FREE in Dapper Plus (doesn't require a license). These methods work with one entity at a time, allowing you to use the same customizations as the Bulk
counterparts but without the associated performance enhancements.
The Single Action operations include:
SingleInsert
SingleUpdate
SingleDelete
SingleMerge
Here's an example of how to use the SingleInsert
operation:
foreach(var customer in customers)
{
connection.SingleInsert(customer);
}
In this example, the SingleInsert
method is used within a loop to insert individual customers into the database. Although this approach doesn't provide the performance benefits of the bulk operations, it allows for granular control over each operation compared to write yourself a SQL statement.
Bulk Insert
The BulkInsert
extension method allow you to insert multiple rows with Bulk Operations. This is ideal for scenarios where you have large amounts of data to insert into your database and need a performant way to do so.
Here are some of the common options available:
- InsertIfNotExists: This option ensures only new entities that don't already exist in the database are inserted. This is great for maintaining data integrity and avoiding duplicate entries.
- InsertKeepIdentity: This option allows you to insert specific values into an identity column from your entities. This is useful when you want to maintain the same identity values as in your source data.
Here is an example demonstrating the use of InsertIfNotExists
option with the BulkInsert
method:
connection.UseBulkOptions(options => { options.InsertIfNotExists = true;})
.BulkInsert(customers);
In the example above, only those customers who do not already exist in the database will be inserted. This helps prevent duplication and ensures the insertion operation is as efficient as possible.
These options offer extensive control over your bulk insert operations, making Dapper Plus a powerful tool for managing large-scale data operations.
Bulk Update
The Dapper Plus BulkUpdate
method provides an efficient and versatile approach for executing large-scale updates. You can configure the method to tailor your operations according to specific requirements.
Creating an instance context allows you to customize your mapping within a method if you need to use a custom key, or update a subset of your properties:
public void MyMethodName()
{
var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServer());
var context = new DapperPlusContext(connection);
context.Entity<Customer>().Key(x => new { x.Email }).Map(x => new { x.FirstName, x.LastName });
context.BulkUpdate(customers);
}
In the example above, the BulkUpdate
operation updates only the FirstName
and LastName
properties of the customers whose Email
matches the entities in your list. This level of control and flexibility makes it possible to update specific columns based on custom keys, which can be very useful when dealing with complex business rules or performance optimization scenarios.
This is just one of the many ways Dapper Plus can be configured to meet a wide range of operational requirements.
Bulk Delete
The BulkDelete
extension method enables you to perform efficient and large-scale deletion operations. By using this method, you can delete multiple rows simultaneously, saving both time and computational resources.
Asynchronous operation is also supported with BulkDelete
, making it ideal for scenarios where non-blocking operation is critical for application performance. To perform a deletion asynchronously, use the BulkActionAsync
method and call BulkDelete
within:
var task = connection.BulkActionAsync(x => x.BulkDelete(customers), cancellationToken);
In the example above, the deletion operation for a list of customers is carried out asynchronously, enhancing the performance of your application by not blocking the main execution thread.
Asynchronous operations can significantly boost your application's performance when handling large amounts of data, making Dapper Plus an ideal choice for data-intensive .NET applications.
Bulk Merge / Bulk Upsert
The BulkMerge
extension method allow you to execute Upsert
operations using bulk operations. An Upsert
(Update/Insert) operation updates existing rows and inserts non-existing rows.
Several configuration options are available for fine-tuning your BulkMerge
operations:
- ColumnPrimaryKeyExpression: Allows you to define a custom key to verify the existence of entities.
- IgnoreOnMergeInsertExpression: Lets you ignore certain columns during the insert phase of the merge operation.
- IgnoreOnMergeUpdateExpression: Allows you to ignore certain columns during the update phase of the merge operation.
Here is an example showcasing the use of these options:
public void MyMethodName()
{
var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServer());
var context = new DapperPlusContext(connection);
context.Entity<Customer>().UseBulkOptions(x => {
options.ColumnPrimaryKeyExpression = x => new { x.Code };
options.IgnoreOnMergeInsertExpression = x => new { x.UpdatedDate, x.UpdatedBy };
options.IgnoreOnMergeUpdateExpression = x => new { x.CreatedDate, x.CreatedBy };
});
context.BulkMerge(customers);
}
In this example, BulkMerge
is used to upsert a list of customers. The merge operation uses Code
as the primary key. During the insertion phase, UpdatedDate
and UpdatedBy
properties are ignored. During the update phase, CreatedDate
and CreatedBy
properties are ignored.
Effectively utilizing these options, Dapper Plus facilitates robust and flexible upsert operations, enabling complex data manipulation with relative ease and efficiency.
Release Notes
For a detailed account of improvements, bug fixes, and updates in each version of Dapper Plus, we recommend consulting the official Release Notes in our GitHub repository.
The Release Notes provide critical insights about each release, describing new features, acknowledging resolved issues, and noting any breaking changes, if applicable. We strongly recommend reviewing these notes before upgrading to a newer version. This practice ensures that you take full advantage of new features and helps avoid unexpected issues.
License
Dapper Plus operates under a paid licensing model. To acquire a license, please visit our official Pricing Page on the Dapper Plus website. It offers a range of licensing options, so you can choose the one that best fits your needs and requirements.
Product | Versions 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 is compatible. 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 | net40 is compatible. net403 was computed. 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 | 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. |
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.5.0)
- System.Configuration.ConfigurationManager (>= 4.5.0)
-
net6.0
- System.Configuration.ConfigurationManager (>= 4.5.0)
-
net8.0
- System.Configuration.ConfigurationManager (>= 8.0.0)
NuGet packages (12)
Showing the top 5 NuGet packages that depend on Z.Dapper.Plus:
Package | Downloads |
---|---|
Edakik.Shared.Library
Package Description |
|
Leben
Set of programming tools and utilities used by Leben developers. |
|
ClassicAh.Infrastructure.Database
Package Description |
|
Api.Dapper.Utility
基于Dapper封装的DB操作基础层,DBUtility、DALFactory层 |
|
br-dapper-helper
Package Description |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Z.Dapper.Plus:
Repository | Stars |
---|---|
zzzprojects/Dapper-Plus
Dapper Plus - High-Efficient Bulk Actions (Insert, Update, Delete, and Merge) for .NET
|
Version | Downloads | Last updated |
---|---|---|
7.5.6 | 3,308 | 12/10/2024 |
7.5.5 | 8,072 | 11/12/2024 |
7.5.4 | 10,976 | 10/22/2024 |
7.5.3 | 14,645 | 10/2/2024 |
7.5.2 | 27,650 | 8/13/2024 |
7.5.1 | 10,703 | 7/22/2024 |
7.5.0 | 40,869 | 6/18/2024 |
7.4.2 | 17,932 | 5/20/2024 |
7.4.1 | 15,522 | 4/30/2024 |
7.4.0 | 23,757 | 3/26/2024 |
7.3.1 | 16,541 | 3/12/2024 |
7.3.0 | 23,789 | 2/13/2024 |
7.2.2 | 20,010 | 1/16/2024 |
7.2.1 | 16,043 | 12/12/2023 |
7.2.0 | 3,053 | 12/5/2023 |
7.1.0 | 5,747 | 11/28/2023 |
7.0.0 | 8,784 | 11/15/2023 |
6.0.5 | 23,562 | 10/17/2023 |
6.0.4 | 45,513 | 9/19/2023 |
6.0.3 | 11,822 | 9/11/2023 |
6.0.2 | 18,998 | 8/15/2023 |
6.0.1 | 18,602 | 7/11/2023 |
6.0.0 | 29,371 | 6/12/2023 |
5.0.4 | 113,354 | 5/16/2023 |
5.0.3 | 14,599 | 5/2/2023 |
5.0.2 | 10,387 | 4/17/2023 |
5.0.1 | 138,562 | 3/20/2023 |
5.0.0 | 148,023 | 2/20/2023 |
4.0.39 | 25,364 | 1/24/2023 |
4.0.38 | 5,573 | 1/17/2023 |
4.0.37 | 53,146 | 12/5/2022 |
4.0.36 | 5,169 | 11/22/2022 |
4.0.35 | 3,957 | 11/15/2022 |
4.0.34 | 38,880 | 10/10/2022 |
4.0.33 | 28,438 | 9/12/2022 |
4.0.32 | 40,013 | 8/16/2022 |
4.0.31 | 65,775 | 7/19/2022 |
4.0.30 | 33,572 | 6/14/2022 |
4.0.29 | 100,625 | 5/17/2022 |
4.0.28 | 16,975 | 4/26/2022 |
4.0.27 | 9,558 | 4/12/2022 |
4.0.26 | 154,100 | 3/15/2022 |
4.0.25 | 11,067 | 3/8/2022 |
4.0.24 | 22,756 | 2/22/2022 |
4.0.23 | 13,998 | 2/14/2022 |
4.0.22 | 106,472 | 1/18/2022 |
4.0.21 | 3,245 | 1/11/2022 |
4.0.20 | 60,451 | 12/14/2021 |
4.0.19 | 16,223 | 11/17/2021 |
4.0.18 | 7,480 | 11/9/2021 |
4.0.17 | 54,930 | 10/13/2021 |
4.0.16 | 26,047 | 9/29/2021 |
4.0.15 | 6,929 | 9/22/2021 |
4.0.14 | 7,714 | 9/15/2021 |
4.0.13 | 1,599 | 9/15/2021 |
4.0.12 | 15,130 | 9/8/2021 |
4.0.11 | 15,994 | 8/25/2021 |
4.0.10 | 59,910 | 8/17/2021 |
4.0.9 | 31,168 | 7/13/2021 |
4.0.8 | 59,407 | 7/5/2021 |
4.0.7 | 18,208 | 6/30/2021 |
4.0.6 | 14,898 | 6/14/2021 |
4.0.5 | 46,051 | 5/31/2021 |
4.0.4 | 41,103 | 5/19/2021 |
4.0.3 | 10,151 | 5/12/2021 |
4.0.2 | 28,649 | 4/19/2021 |
4.0.1 | 17,672 | 3/24/2021 |
4.0.0 | 6,421 | 3/16/2021 |
3.0.38 | 2,979 | 3/16/2021 |
3.0.37 | 2,326 | 3/15/2021 |
3.0.36 | 19,418 | 2/23/2021 |
3.0.35 | 2,584 | 2/19/2021 |
3.0.34 | 2,086 | 2/16/2021 |
3.0.33 | 31,004 | 1/27/2021 |
3.0.32 | 12,680 | 1/15/2021 |
3.0.31 | 19,889 | 1/13/2021 |
3.0.30 | 9,550 | 1/5/2021 |
3.0.29 | 97,847 | 12/16/2020 |
3.0.28 | 1,826 | 12/16/2020 |
3.0.27 | 2,056 | 12/14/2020 |
3.0.26 | 10,564 | 12/1/2020 |
3.0.25 | 11,772 | 11/27/2020 |
3.0.24 | 29,621 | 11/11/2020 |
3.0.23 | 50,162 | 11/4/2020 |
3.0.22 | 40,226 | 10/31/2020 |
3.0.21 | 752,652 | 10/11/2020 |
3.0.20 | 38,649 | 9/23/2020 |
3.0.19 | 6,182 | 9/14/2020 |
3.0.18 | 61,307 | 8/11/2020 |
3.0.17 | 9,882 | 7/27/2020 |
3.0.16 | 1,853 | 7/27/2020 |
3.0.15 | 7,830 | 7/12/2020 |
3.0.14 | 64,150 | 6/13/2020 |
3.0.13 | 7,992 | 6/9/2020 |
3.0.12 | 25,123 | 5/22/2020 |
3.0.11 | 4,763 | 5/19/2020 |
3.0.10 | 7,081 | 5/14/2020 |
3.0.9 | 106,293 | 4/14/2020 |
3.0.8 | 98,478 | 4/3/2020 |
3.0.7 | 27,470 | 3/22/2020 |
3.0.6 | 69,600 | 3/16/2020 |
3.0.5 | 50,431 | 2/17/2020 |
3.0.4 | 3,172 | 2/12/2020 |
3.0.3 | 30,430 | 2/11/2020 |
3.0.2 | 3,039 | 2/6/2020 |
3.0.1 | 33,146 | 1/21/2020 |
2.0.12 | 3,169 | 12/29/2019 |
2.0.11 | 13,542 | 12/4/2019 |
2.0.10 | 7,959 | 11/20/2019 |
2.0.9 | 5,216 | 11/12/2019 |
2.0.8 | 3,302 | 10/30/2019 |
2.0.7 | 21,996 | 10/24/2019 |
2.0.6 | 1,938 | 10/24/2019 |
2.0.5 | 2,466 | 10/21/2019 |
2.0.4 | 8,678 | 10/10/2019 |
2.0.3 | 1,861 | 10/10/2019 |
2.0.2 | 37,687 | 9/21/2019 |
2.0.1 | 27,746 | 9/20/2019 |
2.0.0 | 5,261 | 9/17/2019 |
2.0.0-beta1 | 1,653 | 9/16/2019 |
1.6.8 | 9,166 | 9/11/2019 |
1.6.7 | 2,181 | 9/10/2019 |
1.6.6 | 10,814 | 8/24/2019 |
1.6.5 | 116,506 | 7/28/2019 |
1.6.4 | 2,027 | 7/25/2019 |
1.6.3 | 2,463 | 7/25/2019 |
1.6.2 | 21,776 | 6/29/2019 |
1.6.1 | 3,476 | 6/27/2019 |
1.6.0 | 2,070 | 6/26/2019 |
1.5.9 | 75,521 | 5/30/2019 |
1.5.8 | 4,475 | 5/23/2019 |
1.5.7 | 7,494 | 5/20/2019 |
1.5.6 | 2,607 | 5/13/2019 |
1.5.5 | 2,151 | 5/12/2019 |
1.5.4 | 1,983 | 5/10/2019 |
1.5.3 | 16,592 | 4/30/2019 |
1.5.2 | 24,288 | 4/7/2019 |
1.5.1 | 22,908 | 3/30/2019 |
1.5.0 | 2,596 | 3/30/2019 |
1.4.11 | 3,912 | 3/28/2019 |
1.4.10 | 33,741 | 2/27/2019 |
1.4.10-beta1 | 1,735 | 3/28/2019 |
1.4.9 | 10,802 | 2/22/2019 |
1.4.8 | 3,247 | 2/13/2019 |
1.4.7 | 4,771 | 1/30/2019 |
1.4.6 | 13,351 | 1/10/2019 |
1.4.5 | 2,905 | 1/7/2019 |
1.4.4 | 3,446 | 12/30/2018 |
1.4.3 | 8,229 | 11/29/2018 |
1.4.2 | 2,413 | 11/29/2018 |
1.4.1 | 10,591 | 11/14/2018 |
1.4.0 | 15,854 | 10/28/2018 |
1.3.26 | 67,099 | 9/29/2018 |
1.3.25 | 15,564 | 8/30/2018 |
1.3.24 | 4,144 | 8/18/2018 |
1.3.23 | 2,508 | 8/16/2018 |
1.3.22 | 2,378 | 8/14/2018 |
1.3.21 | 5,441 | 7/31/2018 |
1.3.20 | 5,999 | 6/29/2018 |
1.3.19 | 4,035 | 6/19/2018 |
1.3.18 | 6,000 | 5/31/2018 |
1.3.17 | 6,047 | 5/1/2018 |
1.3.16 | 10,790 | 3/30/2018 |
1.3.15 | 2,394 | 3/29/2018 |
1.3.14 | 3,323 | 3/20/2018 |
1.3.13 | 2,846 | 3/14/2018 |
1.3.12 | 4,688 | 2/27/2018 |
1.3.11 | 3,991 | 2/8/2018 |
1.3.10 | 2,815 | 2/6/2018 |
1.3.9 | 2,440 | 2/5/2018 |
1.3.8 | 2,836 | 1/31/2018 |
1.3.7 | 10,214 | 1/16/2018 |
1.3.6 | 5,006 | 12/29/2017 |
1.3.5 | 22,739 | 11/30/2017 |
1.3.4 | 4,314 | 10/30/2017 |
1.3.3 | 3,992 | 9/30/2017 |
1.3.2 | 2,481 | 9/30/2017 |
1.3.1 | 3,448 | 9/13/2017 |
1.2.11 | 8,164 | 8/31/2017 |
1.2.10 | 2,326 | 8/29/2017 |
1.2.9 | 2,490 | 8/23/2017 |
1.2.8 | 2,844 | 8/13/2017 |
1.2.7 | 2,326 | 8/11/2017 |
1.2.6 | 2,824 | 8/2/2017 |
1.2.5 | 3,624 | 7/27/2017 |
1.2.4 | 2,303 | 7/27/2017 |
1.2.3 | 2,535 | 7/25/2017 |
1.2.1 | 2,478 | 7/18/2017 |
1.2.0 | 2,478 | 7/12/2017 |
1.1.5 | 3,486 | 6/29/2017 |