I am not (and will not be) using Entity Framework but I'd like to use NetTopologySuite support for SQL Server. I managed to get it working with PostgreSQL but can't seem to crack it with SQL Server. In Npsql I can read/write the Geometry type without problem but this doesn't seem possible with SQL Server. How can I read/write a Geometry object from NetTopologySuite to SQL Server?
Asked
Active
Viewed 158 times
1
-
Have you read the [NetTopologySuite.IO.SqlServerBytes](https://github.com/NetTopologySuite/NetTopologySuite.IO.SqlServerBytes) documentation yet? – AlwaysLearning Aug 28 '22 at 23:46
-
Yes this is what I was doing. But the minute I try to get the value or fill a Data Table I get this: System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.SqlServer.Types, Version=10.0.0.0 I thought that by using NetTopologySuite I wouldn't have to reference this assembly which would make the whole thing no longer work on .NET Core. – mxcolin Aug 29 '22 at 04:05
-
Yeah, this is all kinds of broken. GetFieldType on SqlDataReader returns null for Geometry columns, but you can get the value, assuming you get past this. However, this completely breaks SqlDataAdapter.Fill. 2022 and we're still wrestling with this, oh boy. – mxcolin Aug 29 '22 at 20:46
-
In my previous testing it was actually `DataTable.Load()` that breaks behind `SqlDataAdapter.Fill()` when it's trying to enumerate the field types of the columns. If only this stuff looked at TypeConverters. – AlwaysLearning Aug 29 '22 at 21:58