Ich habe das Nuget Microsoft.SqlServer.Types
installiert und habe eine Version des DLL-Problems. Ich habe die readme und hinzugefügt, um die Zeile in der global.asax (Webform web app)Microsoft.SqlServer.Types.SqlGeography DLLs in GAC
protected void Application_Start(object sender, EventArgs e)
{
SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
}
Eine Ausnahme vom Typ 'System.InvalidCastException' lesen in System.Data.DataSetExtensions.dll aufgetreten war aber nicht behandelt im Benutzercode
Weitere Informationen: [A] Microsoft.SqlServer.Types.SqlGeography kann nicht durchgeführt werden, um [B] Microsoft.SqlServer.Types.SqlGeography. Typ A ist von Microsoft.SqlServer.Types, Version = 10.0.0.0, Culture = Neutral, PublicKeyToken = 89845dcd8080cc91 im Kontext standardmäßig Standard-Standort C: \ WINDOWS \ Assembly \ GAC_MSIL \ Microsoft.SqlServer.Types \ 10.0.0.0__89845dcd8080cccc \ Microsoft.SqlServer.Types.dll. Typ B ist kompatibel mit Microsoft.SqlServer.Types, Version = 11.0.0.0, Culture = Neutral, PublicKeyToken = 89845dcd8080cc91 im Kontext Standard op location C: \ WINDOWS \ Assembly \ GAC_MSIL \ Microsoft.SqlServer.Types \ 11.0.0.0__89845dcd8080cccc \ Microsoft.SqlServer.Types.dll.
es auf dieser Linie fehlgeschlagen:
var bla = myDataTable.AsEnumerable().Select(x => new
{
Loc = x.Field<Microsoft.SqlServer.Types.SqlGeography>("theLocation") // breaks
}).ToList();
Thelocation von Datentyp Geographie ist leider für mich in meinem SQL Server 2008, so dass keine 2016 FOR JSON PATH
Option.
ps. Einige Hintergrundinformationen: Ich habe nuget GeoJSON.Net und GeoJSON.Net.Contrib.MsSqlSpatial installiert, um die Geography-Datentypzeilen als Geojson zu erhalten. Oder sollte ich einfach .tostring in meinem SQL hinzufügen und es als Geojson-Punkt analysieren?