Skip to content

Commit

Permalink
Use BinaryImporter WriteNullAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
redbaty committed Oct 2, 2023
1 parent c8a36a5 commit 8aaff52
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion PgBulk.EFCore/PgBulk.EFCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
<PackageProjectUrl>https://github.com/redbaty/PgBulk</PackageProjectUrl>
<PackageVersion>1.1.9</PackageVersion>
<PackageVersion>1.1.10</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
15 changes: 13 additions & 2 deletions PgBulk/NpgsqlBinaryImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,19 @@ public async Task<ulong> WriteToBinaryImporter(IEnumerable<T> entities)
{
await BinaryImporter.StartRowAsync();

foreach (var columnValue in Columns.Select(i => i.GetValue(entity)))
await BinaryImporter.WriteAsync(columnValue);
foreach (var column in Columns)
{
var value = column.GetValue(entity);

if (value == null)
{
await BinaryImporter.WriteNullAsync();
}
else
{
await BinaryImporter.WriteAsync(value);
}
}

inserted++;
}
Expand Down
2 changes: 1 addition & 1 deletion PgBulk/PgBulk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
<PackageProjectUrl>https://github.com/redbaty/PgBulk</PackageProjectUrl>
<PackageVersion>1.1.6</PackageVersion>
<PackageVersion>1.1.7</PackageVersion>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
Expand Down

0 comments on commit 8aaff52

Please sign in to comment.