Skip to content

Commit b0c27b1

Browse files
authored
Merge pull request #256 from Plasma/fix-npgsql-v5-compile-error
Fix compilation error building Npgsql 5 package
2 parents 0ecf35b + be0e6cf commit b0c27b1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Hangfire.PostgreSql/Hangfire.PostgreSql.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
<Choose>
5151
<When Condition="'$(NpgsqlVersion)' == '5'">
5252
<PropertyGroup>
53+
<!--For pre-processor directive use in source code -->
54+
<DefineConstants>USING_NPGSQL_VERSION_5</DefineConstants>
5355
<PackageId>Hangfire.PostgreSql.Npgsql5</PackageId>
5456
</PropertyGroup>
5557
<ItemGroup>

src/Hangfire.PostgreSql/PostgreSqlStorage.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,13 @@ internal NpgsqlConnection CreateAndOpenConnection()
225225

226226
if (!Options.EnableTransactionScopeEnlistment)
227227
{
228-
if (connection.Settings.Enlist)
228+
NpgsqlConnectionStringBuilder connectionStringBuilder;
229+
#if !USING_NPGSQL_VERSION_5
230+
connectionStringBuilder = connection.Settings;
231+
#else
232+
connectionStringBuilder = new(connection.ConnectionString);
233+
#endif
234+
if (connectionStringBuilder.Enlist)
229235
{
230236
throw new ArgumentException(
231237
$"TransactionScope enlistment must be enabled by setting {nameof(PostgreSqlStorageOptions)}.{nameof(Options.EnableTransactionScopeEnlistment)} to `true`.");

0 commit comments

Comments
 (0)