Net4x.SqlServer.Types
4.0.0
dotnet add package Net4x.SqlServer.Types --version 4.0.0
NuGet\Install-Package Net4x.SqlServer.Types -Version 4.0.0
<PackageReference Include="Net4x.SqlServer.Types" Version="4.0.0" />
paket add Net4x.SqlServer.Types --version 4.0.0
#r "nuget: Net4x.SqlServer.Types, 4.0.0"
// Install Net4x.SqlServer.Types as a Cake Addin #addin nuget:?package=Net4x.SqlServer.Types&version=4.0.0 // Install Net4x.SqlServer.Types as a Cake Tool #tool nuget:?package=Net4x.SqlServer.Types&version=4.0.0
Microsoft.SqlServer.Types
a .NET Standard implementation of the spatial types in Microsoft.SqlServer.Types
.
Difference between v1.x and v2.x
The v1.x and v2.x versions are identical and kept in sync. The only difference is the dependency:
- v1.x : Depends on the legacy
System.Data.SqlClient
package. - v2.x : Depends on updated
Microsoft.Data.SqlClient
package.
Examples
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/previous-versions/sql/2014/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.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net35 is compatible. net40 is compatible. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 3.5
- Net4x.ValueTuple (>= 1.1.0)
- NuGetUtility (>= 2.0.10)
-
.NETFramework 4.0
- Net4x.ValueTuple (>= 1.1.0)
- NuGetUtility (>= 2.0.10)
-
.NETFramework 4.5
- Net4x.ValueTuple (>= 1.1.0)
- NuGetUtility (>= 2.0.10)
- System.Memory (>= 4.5.5)
-
.NETStandard 2.0
- Net4x.ValueTuple (>= 1.1.0)
- NuGetUtility (>= 2.0.10)
- System.Data.SqlClient (>= 4.8.5)
- System.Memory (>= 4.5.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.0.0 | 187 | 8/27/2023 |
Added SqlGeography.AsTextZM(). Greatly improved WKT text and writing and closer match behavior of SQL Server.