forked from PostgreSQLCopyHelper/PostgreSQLCopyHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request PostgreSQLCopyHelper#45 from PostgreSQLCopyHelper/…
…Start-Of-Async Async Support
- Loading branch information
Showing
27 changed files
with
110 additions
and
62 deletions.
There are no files selected for viewing
3 changes: 1 addition & 2 deletions
3
PostgreSQLCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper.Test/ArrayTypesTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
PostgreSQLCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper.Test/BasicDataTypesTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...LCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper.Test/Extensions/NpgsqlExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...SQLCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper.Test/Issues/Issue1_QuotingTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...lper/PostgreSQLCopyHelper/PostgreSQLCopyHelper.Test/Issues/Issue2_MixedCaseEntity_Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...QLCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper.Test/NullableBasicDataTypesTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
PostgreSQLCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper.Test/TransactionalTestBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...SQLCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/Extensions/ArrayTypeExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...pyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/Extensions/BinaryDataTypeExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...opyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/Extensions/BitStringTypeExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...LCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/Extensions/BooleanTypeExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...opyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/Extensions/CharacterTypeExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...CopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/Extensions/DateTimeTypeExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...reSQLCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/Extensions/JsonTypeExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...CopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/Extensions/MonetaryTypeExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...eSQLCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/Extensions/UUIDTypeExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
PostgreSQLCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/IPostgreSQLCopyHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
// Copyright (c) Philipp Wagner. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Npgsql; | ||
|
||
namespace PostgreSQLCopyHelper | ||
{ | ||
public interface IPostgreSQLCopyHelper<TEntity> | ||
{ | ||
ulong SaveAll(NpgsqlConnection connection, IEnumerable<TEntity> entities); | ||
ValueTask<ulong> SaveAllAsync(NpgsqlConnection connection, IEnumerable<TEntity> entities, CancellationToken cancellationToken = default); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
PostgreSQLCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/Model/TableDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...pyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/Utils/NoSynchronizationContextScope.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Code taken from https://github.com/npgsql/npgsql/blob/dev/src/Npgsql/NoSynchronizationContextScope.cs | ||
|
||
using System; | ||
using System.Threading; | ||
|
||
namespace PostgreSQLCopyHelper.Utils | ||
{ | ||
/// <summary> | ||
/// This mechanism is used to temporarily set the current synchronization context to null while | ||
/// executing Npgsql code, making all await continuations execute on the thread pool. This replaces | ||
/// the need to place ConfigureAwait(false) everywhere, and should be used in all surface async methods, | ||
/// without exception. | ||
/// | ||
/// Warning: do not use this directly in async methods, use it in sync wrappers of async methods | ||
/// (see https://github.com/npgsql/npgsql/issues/1593) | ||
/// </summary> | ||
/// <remarks> | ||
/// http://stackoverflow.com/a/28307965/640325 | ||
/// </remarks> | ||
internal static class NoSynchronizationContextScope | ||
{ | ||
internal static Disposable Enter() | ||
{ | ||
var sc = SynchronizationContext.Current; | ||
SynchronizationContext.SetSynchronizationContext(null); | ||
return new Disposable(sc); | ||
} | ||
|
||
internal struct Disposable : IDisposable | ||
{ | ||
private readonly SynchronizationContext _synchronizationContext; | ||
|
||
internal Disposable(SynchronizationContext synchronizationContext) | ||
=> _synchronizationContext = synchronizationContext; | ||
|
||
public void Dispose() | ||
=> SynchronizationContext.SetSynchronizationContext(_synchronizationContext); | ||
} | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
PostgreSQLCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/Utils/NpgsqlUtils.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
PostgreSQLCopyHelper/PostgreSQLCopyHelper/PostgreSQLCopyHelper/Utils/StringExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters