Dapper With Geography
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
I'm trying to retrieve SQL Geography using dapper through Stored procedure, but it's gives error:
System.Data.DataException: 'Error parsing column 14 (GeoData=)'
InvalidCastException: Unable to cast object of type 'Microsoft.SqlServer.Types.SqlGeography' to type 'Microsoft.Data.SqlClient.Server.IBinarySerialize'.
Dapper.EntityFramework.Handlers.Register(); added to ConfigureServices in startup
also tried to add
`AssemblyLoadContext.Default.Resolving += Default_Resolving;
private static System.Reflection.Assembly Default_Resolving(AssemblyLoadContext assemblyLoadContext, System.Reflection.AssemblyName assemblyName)
{
try
{
AssemblyLoadContext.Default.Resolving -= Default_Resolving;
return assemblyLoadContext.LoadFromAssemblyName(assemblyName);
}
catch
{
if (assemblyName.Name == "Microsoft.SqlServer.Types")
return typeof(SqlGeography).Assembly;
throw;
}
finally
{
AssemblyLoadContext.Default.Resolving += Default_Resolving;
}
}`
- Dapper 2.0.123
- Dapper.EntityFramework 2.0.90
- .NET Core 6.0
- Microsoft.EntityFrameworkCore.Relational 6.0.3
- Microsoft.SqlServer.Types 14.0.1016.290
- NetTopologySuite.IO.GeoJSON 2.0.4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin by reproducing the stored-procedure query from ConfigureServices with Dapper 2.0.123, Dapper.EntityFramework 2.0.90, .NET 6, and Microsoft.SqlServer.Types 14.0.1016.290. Trace the GeoData column handling and the SqlGeography-to-IBinarySerialize cast, then verify that geography retrieval no longer raises the reported DataException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100