EF 5 Features
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 new class.
An example of how to write a point data is shown here using Connector/Net 6.7 and MySQL Server
5.6.7 or further.
//Storing a geometry point
MySqlConnection conn = new MySqlConnection("server=localhost;userid=root;database=testgeo;");
MySqlCommand cmd = new MySqlCommand("CREATE TABLE Test (v Geometry NOT NULL)");
cmd.Connection = conn;
cmd = new MySqlCommand("INSERT INTO Test VALUES(GeomFromText(?v))", conn);
cmd.Parameters.Value = "POINT(47.37-122.21)";
cmd.CommandText = "SELECT AsText(v) FROM Test";
using(MySqlDataReader reader = cmd.ExecuteReader())
varval = reader.GetValue(0);
... zobacz całą notatkę