DapperLib / Dapper

Dapper - a simple object mapper for .Net
https://www.learndapper.com/
Other
17.59k stars 3.68k forks source link

Support for EF Core spatial data #1366

Open lettucebo opened 5 years ago

lettucebo commented 5 years ago

Now EF Core support for spatial data begin from EF Core 2.2 and using NetTopologySuite as spatial data type base

Is there any plan for support NetTopologySuite Geometry data type?

https://docs.microsoft.com/en-us/ef/core/modeling/spatial

mgravell commented 5 years ago

Great question. Now that this exists, we should investigate.

lettucebo commented 5 years ago

I have implement one version for Entity Framework Core https://github.com/lettucebo/Dapper/tree/master/Dapper.EntityFrameworkCore

While I'm going to try is this out, I stuck at a strange point, saying it can't find Microsoft.SqlServer.Types but I quite sure I never touch Microsoft.SqlServer.Types no matter from Dapper or my test project

And the exception message seems come from System.Data.SqlClient :

FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'. The system cannot find the file specified.

Annotation 2019-11-01 002339

Need some help insight


Reference https://github.com/dotnet/SqlClient/issues/30#issuecomment-459540715

michaelgregson commented 5 years ago

Thank you @lettucebo; great stuff.

Same issue here, setting the column type to Geography in MSSQL seems to instruct the System.Data.SqlClient to use SqlGeography type from Microsoft.SqlServer.Types only when reading.

Adding a reference to Microsoft.SqlServer.Types solves the error.

lettucebo commented 5 years ago

@michaelgregson

Yes, but I want to run my ASP.NET Core web application on Linux

Since Microsoft.SqlServer.Types is base on .NET Framework, so it might not work on Linux platform

steveoh commented 4 years ago

I just bumped into this issue myself...

The member shape of type NetTopologySuite.Geometries.Geometry cannot be used as a parameter value

This would be wonderful if it worked...

carlin-q-scott commented 3 years ago

For using Points as geography, I found this very simple mapper works with Npgsql:

            SqlMapper.AddTypeHandler(typeof(Point), new SqlMapper.UdtTypeHandler("geography"));