SqlGeography support was added in the next version, again through the Dapper.EntityFramework package . I have not built / deployed yet, as I have two minds about whether this is the most suitable assembly for this to live ... but I also do not want to depend on Microsoft.SqlServer.Types in the kernel library. However, there may be a way to do this without it.
Update: now it has moved to the level in the main library, so you do not need any EF or Dapper.EntityFramework ; it should just work; it was clicked like Dapper 1.32 .
Example:
public void SqlGeography_SO25538154() { Dapper.SqlMapper.ResetTypeHandlers(); // to show it doesn't depend on any connection.Execute("create table #SqlGeo (id int, geo geography)"); var obj = new HazSqlGeo { Id = 1, Geo = SqlGeography.STLineFromText( new SqlChars(new SqlString( "LINESTRING(-122.360 47.656, -122.343 47.656 )")), 4326) }; connection.Execute("insert #SqlGeo(id, geo) values (@Id, @Geo)", obj); var row = connection.Query<HazSqlGeo>( "select * from #SqlGeo where id=1").SingleOrDefault(); row.IsNotNull(); row.Id.IsEqualTo(1); row.Geo.IsNotNull(); } class HazSqlGeo { public int Id { get; set; } public SqlGeography Geo { get; set; } }
Marc gravell
source share