Writing NetTopologysuite Point geometry to PostgreSQL with fluent nhibernate fails due to custom type mapping

37 Views Asked by At

I just copied some outdated code to a new project with latest libs and writing of NTS geometries to PostgreSQL no longer works. Anyone has a hint for me?

DB setup is done as follows:

var db = PostgreSQLConfiguration.PostgreSQL83;
return db
  .ConnectionString(connectionstring)
  .AdoNetBatchSize(20)
  .Dialect<NHibernate.Spatial.Dialect.PostGis30Dialect>();

The geometry is mapped as follows:

Map(x => x.Geom).CustomType<PostGisGeometryType>();

The error is the following:

System.InvalidCastException: Writing values of 'NetTopologySuite.Geometries.Point' is not supported for parameters having NpgsqlDbType 'Bytea'.
   at Npgsql.Internal.AdoSerializerHelpers.<GetTypeInfoForWriting>g__ThrowWritingNotSupported|1_0(Type type, PgSerializerOptions options, Nullable`1 pgTypeId, Nullable`1 npgsqlDbType, Exception inner)
   at Npgsql.Internal.AdoSerializerHelpers.GetTypeInfoForWriting(Type type, Nullable`1 pgTypeId, PgSerializerOptions options, Nullable`1 npgsqlDbType)

Cheers, Martin

0

There are 0 best solutions below