dotMorten.Microsoft.SqlServer.Types 1.2.0

Allows you to use SQL Server spatial SqlHierarchy types on a machine without SQL Server installed and decode these UDT types in any .NET Standard client

Install-Package dotMorten.Microsoft.SqlServer.Types -Version 1.2.0
dotnet add package dotMorten.Microsoft.SqlServer.Types --version 1.2.0
<PackageReference Include="dotMorten.Microsoft.SqlServer.Types" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add dotMorten.Microsoft.SqlServer.Types --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Microsoft.SqlServer.Types

a .NET Standard implementation of the spatial types in Microsoft.SqlServer.Types

Sponsoring

If you like this library and use it a lot, consider sponsoring me. Anything helps and encourages me to keep going.

See here for details: https://github.com/sponsors/dotMorten

NuGet:

Install the package dotMorten.Microsoft.SqlServer.Types from NuGet.

Usage

Input parameter

Assigning SqlGeometry or SqlGeography to a command parameter:

   command.Parameters.AddWithValue("@GeographyColumn", mySqlGeography);
   command.Parameters["@GeometryColumn"].UdtTypeName = "Geography";

   command.Parameters.AddWithValue("@GeographyColumn", mySqlGeometry);
   command.Parameters["@GeometryColumn"].UdtTypeName = "Geometry" 

The geometry will automatically be correctly serialized.

Reading geometry and geography

Use the common methods for getting fields of specific types:

   var geom1 = reader.GetValue(geomColumn) as SqlGeometry;
   var geom2 = reader.GetFieldValue<SqlGeometry>(geomColumn);
   var geom3 =  = SqlGeometry.Deserialize(reader.GetSqlBytes(geomColumn)); //Avoids any potential assembly-redirect issue. See https://docs.microsoft.com/en-us/sql/sql-server/install/warning-about-client-side-usage-of-geometry-geography-and-hierarchyid?view=sql-server-2014#corrective-action

Notes:

The spatial operations like intersection, area etc are not included here. You can perform these as part of your query instead and get them returned in a column.

Microsoft.SqlServer.Types

a .NET Standard implementation of the spatial types in Microsoft.SqlServer.Types

Sponsoring

If you like this library and use it a lot, consider sponsoring me. Anything helps and encourages me to keep going.

See here for details: https://github.com/sponsors/dotMorten

NuGet:

Install the package dotMorten.Microsoft.SqlServer.Types from NuGet.

Usage

Input parameter

Assigning SqlGeometry or SqlGeography to a command parameter:

   command.Parameters.AddWithValue("@GeographyColumn", mySqlGeography);
   command.Parameters["@GeometryColumn"].UdtTypeName = "Geography";

   command.Parameters.AddWithValue("@GeographyColumn", mySqlGeometry);
   command.Parameters["@GeometryColumn"].UdtTypeName = "Geometry" 

The geometry will automatically be correctly serialized.

Reading geometry and geography

Use the common methods for getting fields of specific types:

   var geom1 = reader.GetValue(geomColumn) as SqlGeometry;
   var geom2 = reader.GetFieldValue<SqlGeometry>(geomColumn);
   var geom3 =  = SqlGeometry.Deserialize(reader.GetSqlBytes(geomColumn)); //Avoids any potential assembly-redirect issue. See https://docs.microsoft.com/en-us/sql/sql-server/install/warning-about-client-side-usage-of-geometry-geography-and-hierarchyid?view=sql-server-2014#corrective-action

Notes:

The spatial operations like intersection, area etc are not included here. You can perform these as part of your query instead and get them returned in a column.

Release Notes

Strong-name signed so the UDT types will automatically deserialize

NuGet packages (6)

Showing the top 5 NuGet packages that depend on dotMorten.Microsoft.SqlServer.Types:

Package Downloads
EntityFrameworkCore.SqlServer.HierarchyId.Abstractions
Adds hierarchyid support to the SQL Server EF Core provider
DAL.Standard
DAL.Standard is a light weight wrapper around ADO.NET objects to make working with sql dbs simple and easy.
GeoFlux.SqlConnectionWithHierarchyId
Add SqlHierarchyId support to SqlConnection
TableSync
A component to synchronize data between Microsoft SQL Server and Excel files in OpenXML format (xlsx).
linq2db.LINQPad
Supported databases: IBM DB2 LUW/zOS, Firebird, IBM Informix, Microsoft Access, Microsoft Sql Server (+Azure), Microsoft Sql Server Compact, MySql, MariaDB, Oracle, PostgreSQL, SQLite, SAP HANA, SAP/Sybase ASE.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on dotMorten.Microsoft.SqlServer.Types:

Repository Stars
sjh37/EntityFramework-Reverse-POCO-Code-First-Generator
EntityFramework Reverse POCO Code First Generator - Beautifully generated code that is fully customisable. This generator creates code as if you reverse engineered a database and lovingly created the code by hand. It is free to academics (you need a .edu or a .ac email address), not free for commercial use. Obtain your licence from

Version History

Version Downloads Last updated
1.2.0 393 9/9/2020
1.1.0 82,484 10/29/2018