I am trying to get Polygon data from MySQL in my C # application.
I precisely defined in one table the Polygon field where geodata are stored.
Evidence:
SELECT GeometryType(GeomFromText(AsWKT(object))) as `type` FROM geo.data;
Return:

Thus, the object in the table is accurate and correct.
C # has the source code:
http://ideone.com/bn1urQ
And the main lines are (73-76):
//var polygon = (byte[])reader["object"]; //var obj = new MySqlGeometry(MySqlDbType.Blob, polygon); var polygon = reader["object"].ToString(); var obj = MySqlGeometry.Parse(polygon);
I commented on this, but it is not an obstacle to tell you about all the operations:
- extract as a
BLOB with the following deserialization - parsing a string using the
MySqlGeometry.Parse(System.String) method MySqlGeometry.Parse(System.String)
Download BLOB
Well, I'll start with the commented part of the code, let's imagine that these lines are uncommented and there are no lines 75 and 76 with parsing of the lines.
There is also another correction, the SQL query that is sent to the MySQL server should look like this:
SELECT AsWKB(object) as 'object' FROM geo.data
I just changed the AsWKT() function to AsWKT() in a SQL query (from text to binary formatting in MySQL).
So, the result of this query will be:

In the lines:
var polygon = (byte[])reader["object"]; var obj = new MySqlGeometry(MySqlDbType.Blob, polygon);
You can see that I am extracting a BLOB object and then converting it to a System.Byte[] array, and only then I try to create MySqlGeomerty , but I am very sorry and it looks like MySQL Libraries identify this object as a POINT , not a Polygon .
Evidence:

But!!! I definitely have a Polygon object in MySQL with the following SQL query:
SELECT GeometryType(GeomFromText(AsWKT(object))) as `type`, AsWKT(object) as `data` FROM geo.data
Evidence:

It was a BLOB object.
Parsing geometry from System.String
Now ... Submit the original source with BLOB comments.
Let's look at the lines:
var polygon = reader["object"].ToString(); var obj = MySqlGeometry.Parse(polygon);
And change the SQL query in the source code of the C # application to:
SELECT AsWKT(object) as 'object' FROM geo.data
Yes ... MySQL libraries for .NET provide an allegedly different style of building geometries, from System.String .
But, when I try to parse var polygon , which is extracted correctly, as you saw above, I get the following error:
System.FormatException: String does not contain a valid geometry value
Evidence:


It all looks like this: MySQL libraries do not provide complete structures for binding data from the MySQL server.