3

Using SQL Server Management Studio:

declare @g geography
set @g = geography::Point(-77.1851436,39.1065236,4326)
select @g

returns

0xE6100000010C14C48A64D94B53C04820B990A28D4340

What format is this result? I know that it is not STAsBinary() - that returns

0x01010000004820B990A28D434014C48A64D94B53C0

Is there a way to create the 0xE61... value using C#?

AAsk
  • 1,431
  • 4
  • 17
  • 25

2 Answers2

4

This is special binary format defined here (you may download PDF there if interested about details of that format). You can create such value in C# like this (reference Microsoft.SqlServer.Types assembly):

var pt = SqlGeography.Point(-77.1851436, 39.1065236, 4326);    
var binary = pt.Serialize().Value;
var hexString = "0x" + BitConverter.ToString(binary).Replace("-", "");
Evk
  • 98,527
  • 8
  • 141
  • 191
2

result is type of Microsoft.SqlServer.Types.SqlGeography.Point

see this link

ali zarei
  • 1,212
  • 11
  • 17