Skip to content

Comments

Add option to preserve CancellationToken parameters#115

Open
0xced wants to merge 1 commit intozompinc:masterfrom
0xced:PreserveCancellationToken
Open

Add option to preserve CancellationToken parameters#115
0xced wants to merge 1 commit intozompinc:masterfrom
0xced:PreserveCancellationToken

Conversation

@0xced
Copy link
Contributor

@0xced 0xced commented Feb 23, 2026

It can still be useful to preserve the CancellationToken in some scenarios. For example, for cancelling a synchronous bulk copy operation.

bulkCopy.SqlRowsCopied += (_, e) =>
{
    if (cancellationToken.IsCancellationRequested)
    {
        e.Abort = true;
    }
};

I plan to submit a pull request at PhenX.EntityFrameworkCore.BulkInsert to use Sync Method Generator in order to greatly simplify async + sync methods implementations. 😉

@0xced 0xced force-pushed the PreserveCancellationToken branch 2 times, most recently from 6750016 to ffe5b3f Compare February 23, 2026 17:18
It can still be useful to preserve the CancellationToken in some scenarios. For example, for [cancelling a synchronous bulk copy operation][1].

```csharp
bulkCopy.SqlRowsCopied += (_, e) =>
{
    if (cancellationToken.IsCancellationRequested)
    {
        e.Abort = true;
    }
};
```

I plan to submit a pull request at [PhenX.EntityFrameworkCore.BulkInsert][2] to use *Sync Method Generator* in order to greatly simplify async + sync methods implementations. 😉

[1]: https://github.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/blob/137d2fc8fed17b5aa7e6f11fccc079b7f463aff0/src/PhenX.EntityFrameworkCore.BulkInsert.SqlServer/SqlServerBulkInsertProvider.cs#L68-L74
[2]: https://github.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert
@0xced 0xced force-pushed the PreserveCancellationToken branch from ffe5b3f to 1f0b33f Compare February 23, 2026 17:35
0xced added a commit to 0xced/PhenX.EntityFrameworkCore.BulkInsert that referenced this pull request Feb 23, 2026
…rt sync + async versions

TODO: Wait for zompinc/sync-method-generator#115 to be merged and a new version to be released instead of using a ProjectReference which only works when the sync-method-generator repository is cloned at the right place on the right branch.

In addition to simplifying the implementation, it also fixes "await using var partialInsertCommand" on the synchronous path in SqliteBulkInsertProvider.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant