I installed the Nuget Microsoft.SqlServer.Types
and have a version of DLL issue.
I have read the readme and added the line in the global.asax (Webform web app)
protected void Application_Start(object sender, EventArgs e)
{
SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
}
An exception of type 'System.InvalidCastException' occurred in System.Data.DataSetExtensions.dll but was not handled in user code
Additional information: [A]Microsoft.SqlServer.Types.SqlGeography kan niet worden geconverteerd naar [B]Microsoft.SqlServer.Types.SqlGeography. Type A is afkomstig uit Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 in de context Default op locatie C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.Types\10.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Types.dll. Type B is afkomstig uit Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 in de context Default op locatie C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.Types\11.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Types.dll.
It failed on this line:
var bla = myDataTable.AsEnumerable().Select(x => new
{
Loc = x.Field<Microsoft.SqlServer.Types.SqlGeography>("theLocation") // breaks
}).ToList();
theLocation is of datatype geography in my Sql Server 2008, so no 2016 FOR JSON PATH
option for me unfortunatly.
ps. some background info: I installed nuget GeoJSON.Net and GeoJSON.Net.Contrib.MsSqlSpatial to get the geography datatype rows as geojson. Or should I just add .tostring in my sql and parse it as geojson point?