fsprojects / FSharp.Data.SqlClient

A set of F# Type Providers for statically typed access to MS SQL database
http://fsprojects.github.io/FSharp.Data.SqlClient/
Other
205 stars 71 forks source link

Add support for NetTopologySuite #369

Open daniellittledev opened 4 years ago

daniellittledev commented 4 years ago

Description

In the past this type provider had support for SqlServer.Types a big part of which are the Spatial Data Types for SQLServer.

Today with the move to dotnetcore Microsoft.SqlServer.Types are no longer supported (only full framework). Dapper and Entityframework core both support NetTopologySuite as a replacement for the Geometry Sql Server Types. This library is much more widely supported and feature complete.

In order once again support Spatial Data Types, and to gain parity with other popular dotnet SQL libraries FSharp.Data.SqlClient should also support Spatial Data Types via NetTopologySuite.

Repro steps

Installing Microsoft.SqlServer.Types shows a warning that the package may not be fully compatible with your project.

Expected behavior

I would expect a path to use Spatial Data Types or support for custom types.

Actual behavior

It is not currently possible to use NetTopologySuite with this type provider.

Known workarounds

Use a different library.

Related information

daniellittledev commented 4 years ago

For reference here is some sample code showing how to use NetTopologySuite with Dapper. https://gist.github.com/bricelam/7eca234674c3ca4150872f899af37611

daniellittledev commented 4 years ago

It looks like the list of supported types can be found here: https://github.com/fsprojects/FSharp.Data.SqlClient/blob/2ef6c06a2844c2a1b61305bc6b78cbeede090915/src/SqlClient.DesignTime/SqlClientExtensions.fs#L120-L130

Which is a list of providerdbtype, clrTypeFullName, and isFixedLength.

Finally these are used to construct TypeInfo records with the following fields.

{
  TypeName = name
  Schema = schema_name
  SqlEngineTypeId = system_type_id
  UserTypeId = user_type_id
  SqlDbType = providerdbtype
  IsFixedLength = isFixedLength
  ClrTypeFullName = clrTypeFullName
  UdttName = if is_table_type then name else ""
  TableTypeColumns = columns
}