1

I wanna use SqlGeography for its benefits in sql server 2016 and I have Visual Studio 2017 while using servicestack 4.5.14 and ormlite.

First and foremost I want to have SqlGeography as data type for my locations but it generates many exception as picture. enter image description here

If I use DbGeography , when I am using servicestack and ormlite as follow:

  Db.Insert(location);

It makes an exception as :

System.Data.SqlClient.SqlException: 'A .NET Framework error occurred 
during execution of user-defined routine or aggregate "geography": 
System.FormatException: 24114: The label {Geography:{Coordina in the 
input well-known text (WKT) is not valid. Valid labels are POINT, 
LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, 
GEOMETRYCOLLECTION, CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON and 
FULLGLOBE (geography Data Type only).
System.FormatException: 
at Microsoft.SqlServer.Types.OpenGisTypes.ParseLabel(String input)
at 

Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText
(OpenGisType type)
at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType 
type, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.ParseText(OpenGisType type, 
SqlChars taggedText, Int32 srid)
at 
Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType 
type, SqlChars taggedText, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.Parse(SqlString s)
.
The statement has been terminated.'
Mahsa Hassankashi
  • 2,086
  • 1
  • 15
  • 25
  • 2
    Can you provide more context regarding the `location` object? Have you followed the instructions here? https://github.com/ServiceStack/ServiceStack.OrmLite/wiki/SQL-Server-Types – Tony Morris Sep 06 '18 at 18:53
  • 1
    @TonyMorris I installed it from pkg mng console "Install-Package ServiceStack.OrmLite.SqlServer.Converters" and I got exception as I showed in picture. Now I solved it by using this part of code with entity frame work 6. – Mahsa Hassankashi Sep 08 '18 at 06:18
  • 1
    I think there is some mismatch version among servicestack + orm lite + visual studio. – Mahsa Hassankashi Sep 08 '18 at 06:18
  • 1
    My version: [ Microsoft.SqlServer.Types -> Version=14.0.0.0 ] + [ Visual Studio 2017 -> Version = 4.6.01586 ] + [ Servicestack -> Version = 4.5.14 ] – Mahsa Hassankashi Sep 08 '18 at 06:31
  • I was looking for more concrete code information regarding the object you were working on and how you were using it. If you solved this problem, please add an answer yourself and mark it as solved. – Tony Morris Sep 10 '18 at 14:13

0 Answers0