Like Dapper, Dapper Plus is a NuGet library where you can add to your project that will extend your IDbConnection
and IDbTransaction
interface with high efficient Bulk Actions Helpers (Insert, Update, Delete, and Merge).
It can be used with or without Dapper, and it's compatible with all other Dapper packages.
// CONFIGURE & MAP entity
DapperPlusManager.Entity<Order>().Table("Orders").Identity(x => x.ID);
// CHAIN & SAVE entity
connection.BulkInsert(orders)
.AlsoInsert(order => order.Items);
.Include(order => order.ThenMerge(order => order.Invoice)
.AlsoMerge(invoice => invoice.Items))
.AlsoMerge(order => order.ShippingAddress);
PM> Install-Package Z.Dapper.Plus
* PRO Version unlocked for the current month
Dapper Plus - Mapper
Dapper Plus Mapper allows to map the conceptual model (Entity) with the storage model (Database) and configure options to perform Bulk Actions.
DapperPlusManager.Entity<Order>().Table("Orders")
.Identity(x => x.ID)
.BatchSize(200);
Bulk Actions allow to perform a bulk insert, update, delete or merge and include related child items.
connection.BulkInsert(orders, order => order.Items)
.BulkInsert(invoices, invoice => invoice.Items)
.BulkMerge(shippingAddresses);
Also Bulk Actions allow to perform bulk action with a lambda expression using entities from the last Bulk[Action] or ThenBulk[Action] used.
connection.BulkInsert(orders)
.AlsoInsert(order => order.Items)
.AlsoInsert(order => order.Invoice)
.AlsoInsert(order => order.Invoice.Items);
Then Bulk Actions is similar to Also Bulk Actions but modifies entities used for the next bulk action using a lambda expression.
connection.BulkInsert(orders)
.AlsoInsert(order => order.Items)
.ThenInsert(order => order.Invoice)
.ThenInsert(invoice => invoice.Items);
The Dapper Plus Include method allows resolving issues with multiple "ThenBulk[Action]" methods.
connection.BulkInsert(orders)
.Include(x => x.ThenInsert(order => order.Items)
.ThenInsert(orderItem => orderItem.Metas))
.Include(x => x.ThenInsert(order => order.Invoice)
.ThenInsert(Invoice => invoice.Items));
All Dapper Plus extension methods are also available on the IDbTransaction
interface
transaction.BulkInsert(orders)
.Include(x => x.ThenInsert(order => order.Items)
.ThenInsert(orderItem => orderItem.Metas))
.Include(x => x.ThenInsert(order => order.Invoice)
.ThenInsert(Invoice => invoice.Items));
All major database providers are supported or under development.
PRO Version unlocked for the current month
Features | PRO Version |
---|---|
Bulk Insert | Yes |
Bulk Update | Yes |
Bulk Delete | Yes |
Bulk Merge | Yes |
Bulk Action Async | Yes |
Bulk Also Action | Yes |
Bulk Then Action | Yes |
Commercial License | Yes |
Royalty-Free | Yes |
Support & Upgrades (1 year) | Yes |
Learn more about the PRO Version.
The best way to contribute is by spreading the word about the library:
A HUGE THANKS for your help.
To view all our free and paid projects, visit our website ZZZ Projects.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。