Dapper Spatial Geography Type

I am preparing some spatial examples and decided to give Dapper, although EF has spatial support and I like to control my SQL again (thanks to Sam and Mark).

However, I need to have POCO supporting the DbGeography class. For instance:

public class BuriedTreasure {
   public int PirateId { get; set; }
   public DbGeography MarksTheSpot { get; set; }
}

My google foo let me go and the closest match I can find is this question, although it is only intended to add spatial support as a parameter (so this is 50%).

Now, as far as I can tell, I am limited to the following options, which for me are not a viable solution.

  • Configure dapper code to understand SQL Server specific type
  • Specify LONG, LAT, and ELEVATION decimal numbers in my POCO and create a SPATIAL type in my stored procedure and ask for another procedure to get the values ​​(or use a constant computed column, but it's almost the same)

Alternatives?

+3
source share
1 answer

For everyone who is interested, in fact, I went to option 2 in the question that I posted above. I have spatial data mapped to decimal places. The stored procedure performs some additional validation, so it would be easy to build, i.e. The following snippet:

Yarrrr = geography::Point(@Latitude, @Longitude, 4326)

In fact, the DbGeography class is immutable, appears to show ... RTFM :)

No changes to dapper required!

0
source

Source: https://habr.com/ru/post/1545945/


All Articles