DapperLib / DapperLib/Dapper

Mapping geography field to a POCO field

Open
#1,170 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

Some context:

  • I'm coding against .NET Standard 2.0
  • UDT types are not yet supported, and I'm using SQL Server.
  • I want to map a geography field to a field in one of my poco's.

Current behaviour:

When trying to map a table which contains a geography field, Dapper throws the following exception:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.Types

Which I find somewhat strange as I thought the UdtTypeHandler was not being compiled for .NET Standard 2.0. Can someone elaborate?

Goal:

I'd be perfectly content if it would be possible to create a custom typehandler for the IPoint interface in which I process the WKB. Currently this custom typehandler is not even called (although it is registered).

To wrap up, is it possible to handle geography fields as if a generic string type field?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the geography mapping against .NET Standard 2.0 and SQL Server, then inspect the UdtTypeHandler path and the registered custom handler for IPoint. Done means geography values can be mapped without the Microsoft.SqlServer.Types load failure, with the custom handler invoked or the supported limitation documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend, database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.