zzzprojects / Dapper-Plus

Dapper Plus - High-Efficient Bulk Actions (Insert, Update, Delete, and Merge) for .NET
https://dapper-plus.net/
380 stars 84 forks source link

How to pass cancellation token to BulkSynchronize? #117

Closed VictorioBerra closed 1 year ago

VictorioBerra commented 1 year ago

Description

Describe the issue or proposed feature.

Allow .BulkSynchronize() to accept a cancellation token

Exception

If you are seeing an exception, include the full exceptions details (message and stack trace).

Exception message:
Stack trace:

Fiddle or Project (Optional)

If you are able,

Provide a Fiddle that reproduces the issue: https://dotnetfiddle.net/kV5RHX

Or provide a project/solution that we can run to reproduce the issue.

Otherwise, make sure to include as much information as possible to help our team to reproduce the issue.

Note: More information you provide, faster we can implement a solution.

Further technical details

JonathanMagnan commented 1 year ago

Hello @VictorioBerra ,

Thank you for reporting.

I will discuss about it with my developer as using the BulkActionAsync is really not obvious.

JonathanMagnan commented 1 year ago

Hello @VictorioBerra ,

Sorry for the long waiting. I just noticed I forgot to give you an example with the BulkActionAsync

Unfortunately, we could not agree on how to add async method to bulk operations such as BulkSynchronize due to how chaining action currently work in Dapper Plus.

Currently, using Async could only be done with the BulkActionAsync.

Here is an example with a cancellation token:

var task = connection.BulkActionAsync(x => x.BulkInsert(invoices).ThenBulkInsert(y => y.InvoiceItems), cancellationToken);

Doc: https://dapper-plus.net/async-action

Best Regards,

Jon