Serialization error for spatial type

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
JoergB
Posts: 5
Joined: Tue 04 Aug 2015 08:48

Serialization error for spatial type

Post by JoergB » Mon 04 Apr 2016 11:59

On a system running .NET 4.5.2 we use Devart dotConnect for Oracle V8.5.616 together with the Entity Framework 6.0 and the NetTopologySuite V1.14.0.

After filling a DataSet using a DbDataAdapter with data of a table containing a column with the spatial data type DbGeography, I try to convert the data into XML using the DataSet's method GetXml. This operation fails with an InvalidOperationException indicating the default constructor is not defined for the class Devart.Data.Oracle.OracleObject.

Am I doing something wrong, or is this functionality not supported yet?

Thank you,
Joerg


StackTrace:

bei System.Xml.Serialization.TypeDesc.CheckSupported()
bei System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)
bei System.Xml.Serialization.ModelScope.GetTypeModel(Type type, Boolean directReference)
bei System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(Type type, XmlRootAttribute root, String defaultNamespace)
bei System.Xml.Serialization.XmlSerializerFactory.CreateSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, String defaultNamespace, String location, Evidence evidence)
bei System.Data.Common.ObjectStorage.GetXmlSerializer(Type type, XmlRootAttribute attribute)
bei System.Data.Common.SqlUdtStorage.ConvertObjectToXml(Object value, XmlWriter xmlWriter, XmlRootAttribute xmlAttrib)
bei System.Data.DataColumn.ConvertObjectToXml(Object value, XmlWriter xmlWriter, XmlRootAttribute xmlAttrib)
bei System.Data.XmlDataTreeWriter.XmlDataRowWriter(DataRow row, String encodedTableName)
bei System.Data.XmlDataTreeWriter.Save(XmlWriter xw, Boolean writeSchema)
bei System.Data.DataSet.GetXml()

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Re: Serialization error for spatial type

Post by Shalex » Mon 04 Apr 2016 15:13

Please use NTS Topology Suite v1.13.2. A similar question was discussed at http://forums.devart.com/viewtopic.php?t=30686.

We will notify you when NTS Topology Suite v1.14 is supported.

JoergB
Posts: 5
Joined: Tue 04 Aug 2015 08:48

Re: Serialization error for spatial type

Post by JoergB » Tue 05 Apr 2016 06:12

Thank you for your response.

So we changed to NTS 1.13.2 and GeoAPI 1.7.2 - but it still throws the same exception...

Do you have any further advice?

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Re: Serialization error for spatial type

Post by Shalex » Thu 07 Apr 2016 13:28

OracleObject could not be serialized because OracleObject depends on opened connection and cannot exist without it.

JoergB
Posts: 5
Joined: Tue 04 Aug 2015 08:48

Re: Serialization error for spatial type

Post by JoergB » Fri 08 Apr 2016 15:04

Is there a work-around for this?
How can I convert the result of a database SELECT which contains a spatial column into XML?

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Re: Serialization error for spatial type

Post by Shalex » Tue 12 Apr 2016 13:43

Instead of

Code: Select all

cmd.CommandText = "select id, geometry from cities";
please use

Code: Select all

cmd.CommandText = "select id, (CASE WHEN Extent1.Geometry IS NULL THEN NULL ELSE 'SRID=' || NVL(Extent1.Geometry.SDO_SRID, '0') || ';' || SDO_UTIL.TO_WKTGEOMETRY(Extent1.Geometry) END) AS Geometry from cities Extent1";
For more information, refer to http://blog.devart.com/using-entity-fra ... rpmap.html.

JoergB
Posts: 5
Joined: Tue 04 Aug 2015 08:48

Re: Serialization error for spatial type

Post by JoergB » Wed 13 Apr 2016 07:25

Thank you for your answer and the provided SQL snippet. It is not what I expected, but at least I now have a work-around. Thank you again for your effort in supporting us.

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Re: Serialization error for spatial type

Post by Shalex » Fri 09 Dec 2016 16:03

dotConnect for Oracle v9.2 includes the following features:
  • Signed versions of NetTopologySuite GIS library are supported in EF5/EF6
  • NetTopologySuite 1.14 is supported in EF5/EF6
  • GeoAPI 1.7.4 is supported in EF5/EF6
For more information, refer to viewtopic.php?f=1&t=34692.

Post Reply