Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

dapper cannot retrieve SqlGeometry #35

Description

@terenceng2010

Issue:

SqlGeometry intersectionPoint = conn.ExecuteScalar<SqlGeometry>(strSql, new { STREET1 = street1, STREET2 = street2 });

and it throw "Object must implement IConvertible"

Solution:

You need to ensure to use a working Microsoft.SqlServer.Types version.

With trial-and-error, it is found that:
if you are pointing to SQL Server 2012 or 2019,
you may use Microsoft.SqlServer.Types v11

Also, you must add the following to the connection string:

Type System Version=SQL Server 2012

Extra issue:
https://blog.developer.money/dapper-%E4%BD%BF%E7%94%A8-microsoft-sqlserver-types-%E6%89%BE%E4%B8%8D%E5%88%B0%E6%AD%A3%E7%A2%BA%E7%89%88%E6%9C%AC%E5%95%8F%E9%A1%8C-a7848b95b6e5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions