Skip to content

Commit 795e03b

Browse files
author
fabien.menager
committed
Merge branch 'main' into feature/oracle
2 parents 9241bd2 + 246c1f4 commit 795e03b

35 files changed

Lines changed: 505 additions & 382 deletions

.github/FUNDING.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# These are supported funding model platforms
2+
3+
github: [PhenX]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12+
polar: # Replace with a single Polar username
13+
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
14+
thanks_dev: # Replace with a single thanks.dev username
15+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/workflows/dotnet-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: dotnet test
55

66
on:
77
push:
8-
branches: [ "master" ]
8+
branches: [ "main" ]
99
pull_request:
10-
branches: [ "master" ]
10+
branches: [ "main" ]
1111

1212
jobs:
1313
build:

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v4
1616

17-
- name: Verify commit exists in origin/master
17+
- name: Verify commit exists in origin/main
1818
run: |
1919
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
20-
git branch --remote --contains | grep origin/master
20+
git branch --remote --contains | grep origin/main
2121
2222
- name: Set Version Variable
2323
if: ${{ github.ref_type == 'tag' }}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,19 @@ Legend :
134134

135135
SQL Server results with 500 000 rows :
136136

137-
![bench-sqlserver.png](https://raw.githubusercontent.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/refs/heads/master/images/bench-sqlserver.png)
137+
![bench-sqlserver.png](https://raw.githubusercontent.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/refs/heads/main/images/bench-sqlserver.png)
138138

139139
PostgreSQL results with 500 000 rows :
140140

141-
![bench-postgresql.png](https://raw.githubusercontent.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/refs/heads/master/images/bench-postgresql.png)
141+
![bench-postgresql.png](https://raw.githubusercontent.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/refs/heads/main/images/bench-postgresql.png)
142142

143143
SQLite results with 500 000 rows :
144144

145-
![bench-sqlite.png](https://raw.githubusercontent.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/refs/heads/master/images/bench-sqlite.png)
145+
![bench-sqlite.png](https://raw.githubusercontent.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/refs/heads/main/images/bench-sqlite.png)
146146

147147
MySQL results with 500 000 rows :
148148

149-
![bench-mysql.png](https://raw.githubusercontent.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/refs/heads/master/images/bench-mysql.png)
149+
![bench-mysql.png](https://raw.githubusercontent.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/refs/heads/main/images/bench-mysql.png)
150150

151151
## Contributing
152152

src/PhenX.EntityFrameworkCore.BulkInsert.MySql/MySqlBulkInsertProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ CancellationToken ctk
7171
sourceOrdinal++;
7272
}
7373

74-
var dataReader = new EnumerableDataReader<T>(entities, properties, options.Converters);
74+
var dataReader = new EnumerableDataReader<T>(entities, properties, options);
7575

7676
if (sync)
7777
{

src/PhenX.EntityFrameworkCore.BulkInsert.MySql/MySqlGeometryConverter.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using MySqlConnector;
1+
using MySqlConnector;
22

33
using NetTopologySuite.Geometries;
44

55
using PhenX.EntityFrameworkCore.BulkInsert.Abstractions;
6+
using PhenX.EntityFrameworkCore.BulkInsert.Options;
67

78
namespace PhenX.EntityFrameworkCore.BulkInsert.MySql;
89

@@ -14,11 +15,11 @@ private MySqlGeometryConverter()
1415
{
1516
}
1617

17-
public bool TryConvertValue(object source, out object result)
18+
public bool TryConvertValue(object source, BulkInsertOptions options, out object result)
1819
{
1920
if (source is Geometry geometry)
2021
{
21-
result = MySqlGeometry.FromWkb(geometry.SRID, geometry.ToBinary());
22+
result = MySqlGeometry.FromWkb(options.SRID, geometry.ToBinary());
2223
return true;
2324
}
2425

src/PhenX.EntityFrameworkCore.BulkInsert.MySql/PhenX.EntityFrameworkCore.BulkInsert.MySql.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="NetTopologySuite" Version="2.6.0" />
13-
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Condition="'$(TargetFramework)' == 'net8.0'" Version="8.0.3" />
13+
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Condition="'$(TargetFramework)' == 'net8.0'" Version="8.0.*" />
1414
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Condition="'$(TargetFramework)' == 'net9.0'" Version="9.0.0-preview.3.efcore.9.0.0" />
1515
</ItemGroup>
1616

src/PhenX.EntityFrameworkCore.BulkInsert.PostgreSql/PhenX.EntityFrameworkCore.BulkInsert.PostgreSql.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
<ItemGroup>
88
<PackageReference Include="NetTopologySuite" Version="2.6.0" />
9-
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Condition="'$(TargetFramework)' == 'net8.0'" Version="8.0.11" />
10-
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Condition="'$(TargetFramework)' == 'net9.0'" Version="9.0.4" />
9+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Condition="'$(TargetFramework)' == 'net8.0'" Version="8.0.*" />
10+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Condition="'$(TargetFramework)' == 'net9.0'" Version="9.0.*" />
1111
</ItemGroup>
1212

1313
</Project>

src/PhenX.EntityFrameworkCore.BulkInsert.PostgreSql/PostgreSqlBulkInsertProvider.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ private static string GetBinaryImportCommand(IReadOnlyList<ColumnMetadata> prope
3535
{
3636
BatchSize = 50_000,
3737
Converters = [PostgreSqlGeometryConverter.Instance],
38-
TypeProviders = [PostgreSqlGeometryConverter.Instance],
3938
};
4039

4140
/// <inheritdoc />
@@ -57,8 +56,6 @@ protected override async Task BulkInsert<T>(
5756
? connection.BeginBinaryImport(command)
5857
: await connection.BeginBinaryImportAsync(command, ctk);
5958

60-
var bulkValueConverters = options.Converters;
61-
6259
// The type mapping can be null for obvious types like string.
6360
var columnTypes = columns.Select(c => GetPostgreSqlType(c, options)).ToArray();
6461

@@ -76,7 +73,7 @@ protected override async Task BulkInsert<T>(
7673

7774
for (var columnIndex = 0; columnIndex < columns.Count; columnIndex++)
7875
{
79-
var value = columns[columnIndex].GetValue(entity, bulkValueConverters);
76+
var value = columns[columnIndex].GetValue(entity, options);
8077

8178
// Get the actual type, so that the writer can do the conversation to the target type automatically.
8279
var type = columnTypes[columnIndex];
Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,33 @@
1-
using Microsoft.EntityFrameworkCore.Metadata;
2-
31
using NetTopologySuite.Geometries;
42

5-
using NpgsqlTypes;
6-
73
using PhenX.EntityFrameworkCore.BulkInsert.Abstractions;
4+
using PhenX.EntityFrameworkCore.BulkInsert.Options;
85

96
namespace PhenX.EntityFrameworkCore.BulkInsert.PostgreSql;
107

11-
internal sealed class PostgreSqlGeometryConverter : IBulkValueConverter, IPostgresTypeProvider
8+
internal sealed class PostgreSqlGeometryConverter : IBulkValueConverter
129
{
1310
public static readonly PostgreSqlGeometryConverter Instance = new();
1411

1512
private PostgreSqlGeometryConverter()
1613
{
1714
}
1815

19-
public bool TryConvertValue(object source, out object result)
16+
public bool TryConvertValue(object source, BulkInsertOptions options, out object result)
2017
{
2118
if (source is Geometry geometry)
2219
{
23-
result = geometry.ToBinary();
24-
return true;
25-
}
20+
if (geometry.SRID != options.SRID)
21+
{
22+
geometry = geometry.Copy();
23+
geometry.SRID = options.SRID;
24+
}
2625

27-
result = source;
28-
return false;
29-
}
30-
31-
public bool TryGetType(IProperty property, out NpgsqlDbType result)
32-
{
33-
if (property.ClrType.IsAssignableTo(typeof(Geometry)))
34-
{
35-
result = NpgsqlDbType.Bytea;
26+
result = geometry;
3627
return true;
3728
}
3829

39-
result = default;
30+
result = source;
4031
return false;
4132
}
4233
}

0 commit comments

Comments
 (0)