Skip to content

A SQL Server IO module for NTS which works directly with the serialization format

License

Notifications You must be signed in to change notification settings

bricelam/NetTopologySuite.IO.SqlServerBytes

 
 

Repository files navigation

NetTopologySuite.IO.SqlServerBytes

A SQL Server IO module for NTS which works directly with the serialization format

License Actions NuGet MyGet (pre-release)
License .NET NuGet MyGet

Usage

Reading

Read geography and geometry columns like this.

var geometryReader = new SqlServerBytesReader { IsGeography = true };
var bytes = dataReader.GetSqlBytes(columnOrdinal).Value;
var geometry = geometryReader.Read(bytes);

Writing

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";

About

A SQL Server IO module for NTS which works directly with the serialization format

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%