Page 1 of 1

SQL Server - Geography Type not supported

Posted: Sun 19 Jun 2016 18:06
by Les Brinkworth
Dear Support,

I am facing an issue where I am executing a tested query on the SQL Server Database (SQL Express 2016) where a table has a column of type Geography.

The query is the following:

Code: Select all

                String sql = String.Format("SELECT * FROM dbo.map_geometry WHERE geometry_store.STContains(geography::STGeomFromText('POINT({0} {1})', 4326)) = 1 AND ShapeName = 'Polygon';", Lat, Lng);
                try
                {
                    var res = context.ExecuteQuery<map_geometry>(sql);
                    return res.ToList();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Unable to test within Polygon.\n" + ex.ToString());
                    return new List<map_geometry>();
                }
This fails with the following error:
System.InvalidOperationException: Invalid data type: GEOGRAPHY
at Devart.Data.SqlServer.Linq.Engine.SqlTypeSystemProviderHelper.a(String A_0, Boolean A_1)
at Devart.Data.SqlServer.Linq.Engine.SqlDataSourceInfo.SqlTypeSystemProvider.ParseProviderType(String typeName)
at Devart.Data.Linq.Engine.DataSourceInfo.TypeSystemProvider.GetProviderType(String typeName)
at Devart.Data.Linq.Engine.DataSourceInfo.TypeSystemProvider.GetProviderType(MetaDataMember member)
at Devart.Data.Linq.Engine.SqlFactory.Default(MetaDataMember member)
at Devart.Data.Linq.Engine.SqlFactory.a(SqlExpression A_0, MetaDataMember A_1)
at Devart.Data.Linq.Engine.de.a(SqlExpression A_0, MetaType A_1, List`1& A_2, List`1& A_3, SqlExpression& A_4, IList`1 A_5)
at Devart.Data.Linq.Engine.de.b(SqlExpression A_0, MetaType A_1, List`1& A_2, List`1& A_3, SqlExpression& A_4, IList`1 A_5)
at Devart.Data.Linq.Engine.de.a(a5 A_0, String A_1, IEnumerable`1 A_2)
at Devart.Data.Linq.Engine.i.b(MethodCallExpression A_0)
at Devart.Data.Linq.Engine.i.j(Expression A_0)
at Devart.Data.Linq.Engine.i.i(Expression A_0)
at Devart.Data.Linq.Engine.dk.d(Expression A_0)
at Devart.Data.Linq.Engine.dk.f(Expression A_0)
at Devart.Data.Linq.DataProvider.c(Expression A_0)
at Devart.Data.Linq.DataContext.ExecuteMethodCall(Object instance, MethodInfo methodInfo, Object[] parameters)
at Devart.Data.Linq.DataContext.ExecuteQuery[TResult](String query, Object[] parameters)
at CalypsoCustomQueries.Geometry.QueriesMapGeometries.WithinPolygon(Double Lat, Double Lng) in C:\Users\Susan\Source\Workspaces\Calypso 2015\CalypsoCustomQueries\CalypsoCustomQueries\QueriesMapGeometries.cs:line 125


Please could you assist with a reason or workaround for the issue.

Re: SQL Server - Geography Type not supported

Posted: Mon 20 Jun 2016 15:07
by Shalex
LinqConnect supports only primitive types: https://www.devart.com/linqconnect/docs ... pping.html.
As a workaround, please use a plain ADO.NET to work with the GEOGRAPHY data type.