Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Deserialize Method
Collapse the table of content
Expand the table of content

SqlGeometry.Deserialize Method

Returns a constructed SqlGeometry from an internal SQL Server format for spatial data.

Namespace:  Microsoft.SqlServer.Types
Assembly:  Microsoft.SqlServer.Types (in Microsoft.SqlServer.Types.dll)

public static function Deserialize(
	bytes : SqlBytes
) : SqlGeometry

Parameters

bytes
Type: SqlBytes
A SqlBytes that specifies the spatial data being sent over the network.

Return Value

Type: Microsoft.SqlServer.Types.SqlGeometry
A SqlGeometry instance that represents the constructed geometry object being sent over the network.

This can be used for reading bytes sent from the server through SqlDataReader. Useful for sending spatial data over the network in conjunction with Serialize().

using (SqlConnection conn = new SqlConnection("..."))
{
      SqlCommand cmd = new SqlCommand("SELECT [SpatialData] FROM [SpatialTable]", conn);
      conn.Open();
      using (SqlDataReader rdr = cmd.ExecuteReader())
      {
            while (rdr.Read())
            {
                  SqlGeometry g = SqlGeometry.Deserialize(reader.GetSqlBytes(0).Stream));
                                                // do some spatial work

            }
}

Community Additions

ADD
Show:
© 2015 Microsoft