Page 1 of 1

Serialization error for spatial type

Posted: Mon 04 Apr 2016 11:59
by JoergB
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()

Re: Serialization error for spatial type

Posted: Mon 04 Apr 2016 15:13
by Shalex
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.

Re: Serialization error for spatial type

Posted: Tue 05 Apr 2016 06:12
by JoergB
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?

Re: Serialization error for spatial type

Posted: Thu 07 Apr 2016 13:28
by Shalex
OracleObject could not be serialized because OracleObject depends on opened connection and cannot exist without it.

Re: Serialization error for spatial type

Posted: Fri 08 Apr 2016 15:04
by JoergB
Is there a work-around for this?
How can I convert the result of a database SELECT which contains a spatial column into XML?

Re: Serialization error for spatial type

Posted: Tue 12 Apr 2016 13:43
by Shalex
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.

Re: Serialization error for spatial type

Posted: Wed 13 Apr 2016 07:25
by JoergB
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.

Re: Serialization error for spatial type

Posted: Fri 09 Dec 2016 16:03
by Shalex
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.