A SQL Server IO module for NTS which works directly with the serialization format
License | Travis | NuGet | MyGet (pre-release) |
---|---|---|---|
Read geography and geometry columns like this.
var geometryReader = new SqlServerBytesReader { IsGeography = true };
var bytes = dataReader.GetSqlBytes(columnOrdinal).Value;
var geometry = geometryReader.Read(bytes);
Write parameters like this.
var geometry = new Point(-122.129797, 47.640049) { SRID = 4326 };
var geometryWriter = new SqlServerBytesWriter { IsGeography = true };
var bytes = geometryWriter.Write(geometry);
var parameter = command.Parameters
.AddWithValue(parameterName, new SqlBytes(bytes));
// TODO: Set these if you're using Microsoft.Data.SqlClient
//parameter.SqlDbType = SqlDbType.Udt;
//parameter.UdtTypeName = "geography";