Spatial Data Type (Geometry type support). Spatial data types support is backed up by the server
capabilities which are documented at: Section 12.18, “Spatial Extensions" There are different types for
spatial data, and the instantiable types that are supported at MySQL are:
Point, LineString, Polygon, GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon.
At Connector/Net these different types can be managed with the new Geometry type. Before
Connector/Net 6.7 the Geometry types didn't have a MySql Type inside the driver. So most of the users
had to use it by using a binary type. This is not longer needed. Now all the specific operations for any
Geometry type can be done by using this newclass.
An example of howto write a point data is shown here using Connector/Net 6.7 and MySQL Server 5.6.7 or further.
//Storing a geometry point MySąlConnection conn - new
MySąlConnection("3erver-1ocalhost;userid-root;database-testgeo;"); conn.Open();
MySąlCommand cmd = new MySąlCommand("CREATE TABLE Test (v Geometry NOT NULL)");
cmd.Connection = conn; cmd.ExecuteNonQuery();
cmd ■ new MySąlCommand("INSERT INTO Test VALUES(GeomFromText(?v))", conn); cmd.Parameters.Add("?v",MySqlDbType.String); cmd.Parameters[0].Value = "POINT(47.37-122.21)"; cmd.ExecuteNonQuery();
cmd.CommandText = "SELECT AsText(v) FROM Test"; using(MySąlDataReader reader = cmd.ExecuteReader())
{
reader.Read();
varval - reader.GetValue(0);
Console.WriteLine(val);
)
conn.Close();