SqlGeometry.Deserialize 方法

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

命名空间:  Microsoft.SqlServer.Types
程序集:  Microsoft.SqlServer.Types(在 Microsoft.SqlServer.Types.dll 中)

语法

声明
Public Shared Function Deserialize ( _
    bytes As SqlBytes _
) As SqlGeometry
用法
Dim bytes As SqlBytes 
Dim returnValue As SqlGeometry 

returnValue = SqlGeometry.Deserialize(bytes)
public static SqlGeometry Deserialize(
    SqlBytes bytes
)
public:
static SqlGeometry^ Deserialize(
    SqlBytes^ bytes
)
static member Deserialize : 
        bytes:SqlBytes -> SqlGeometry
public static function Deserialize(
    bytes : SqlBytes
) : SqlGeometry

参数

返回值

类型: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

            }
}

请参阅

参考

SqlGeometry 类

Microsoft.SqlServer.Types 命名空间