NetTopologySuite.IO.SqlServerBytes icon indicating copy to clipboard operation
NetTopologySuite.IO.SqlServerBytes copied to clipboard

Doesn't work for SqlBulkCopy

Open mxcolin opened this issue 2 years ago • 2 comments

I've tried using this with SqlBulkCopy but I get the following:

System.InvalidOperationException: The given value 'System.Data.SqlTypes.SqlBytes' of type SqlBytes from the data source cannot be converted to type udt for Column 1 [GeoData] Row 1. ---> System.ArgumentException: Specified type is not registered on the target server. System.Data.SqlTypes.SqlBytes, System.Data.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.

I've tried creating the DataColumn as

DataColumn newGeometryColumn = new DataColumn("geo_column", typeof(SqlBytes));

But not sure if that's the right way to achieve this.

mxcolin avatar Sep 26 '22 18:09 mxcolin

Hmm, I'm not sure this is supported by dotnet/SqlClient. Can you file an issue there and see if they know of a way to do it?

bricelam avatar Sep 27 '22 19:09 bricelam

You can do SqlBulkCopy in SqlClient but then you have to reference System.Data.SqlTypes which means it won't work on .Net Core which is why I'm using this library.

mxcolin avatar Oct 04 '22 22:10 mxcolin