forked from PhenX/PhenX.EntityFrameworkCore.BulkInsert
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostgreSqlGeometryConverter.cs
More file actions
33 lines (26 loc) · 847 Bytes
/
PostgreSqlGeometryConverter.cs
File metadata and controls
33 lines (26 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using NetTopologySuite.Geometries;
using PhenX.EntityFrameworkCore.BulkInsert.Abstractions;
using PhenX.EntityFrameworkCore.BulkInsert.Options;
namespace PhenX.EntityFrameworkCore.BulkInsert.PostgreSql;
internal sealed class PostgreSqlGeometryConverter : IBulkValueConverter
{
public static readonly PostgreSqlGeometryConverter Instance = new();
private PostgreSqlGeometryConverter()
{
}
public bool TryConvertValue(object source, BulkInsertOptions options, out object result)
{
if (source is Geometry geometry)
{
if (geometry.SRID != options.SRID)
{
geometry = geometry.Copy();
geometry.SRID = options.SRID;
}
result = geometry;
return true;
}
result = source;
return false;
}
}