EF 5 Features-opracowanie

Nasza ocena:

3
Wyświetleń: 679
Komentarze: 0
Notatek.pl

Pobierz ten dokument za darmo

Podgląd dokumentu
EF 5 Features-opracowanie - strona 1

Fragment notatki:

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;");
conn.Open();
MySqlCommand cmd = new MySqlCommand("CREATE TABLE Test (v Geometry NOT NULL)");
cmd.Connection = conn;
cmd.ExecuteNonQuery();
cmd = new MySqlCommand("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(MySqlDataReader reader = cmd.ExecuteReader())
{
reader.Read();
varval = reader.GetValue(0);
Console.WriteLine(val);
}
conn.Close();
... zobacz całą notatkę

Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz