I've found some related questions, but the author gave up and went ahead with using stored procedures to do the 'mapping'.
This is actually a continuation question from here
Model
public class Store
{
public int Id { get; private set; }
public string Name { get; set; }
public string Address { get; set; }
public DbGeography Location { get; set; }
}
Querying
using (SqlConnection conn = SqlHelper.GetOpenConnection())
{
const string sql = "Select * from Stores";
return conn.Query<Store>(sql, new { Tenant_Id = tenantId });
}
Dapper doesn't understand spatial data, and as many had said, it wasn't the authors original intention to support vendor specific implementations. But the documentation to extend the Query<T>
support is hard to find
I have an exploration into this here, for which the following test passes:
It looks viable, but I haven't dotted every i and crossed every t just yet. You're welcome to experiment with that commit locally - I'd love feedback.