Skip to content

Instantly share code, notes, and snippets.

@lettucebo
Created February 13, 2020 10:27
Show Gist options
  • Save lettucebo/12076a87afdc0c744c25fa9da4e7c86a to your computer and use it in GitHub Desktop.
Save lettucebo/12076a87afdc0c744c25fa9da4e7c86a to your computer and use it in GitHub Desktop.
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Handlers.RegisterGeography();
using (var conn = new SqlConnection(""))
{
string sql = @"
INSERT INTO Coordinates
(Id, UserKey, CreateTime, Feature, UserType, MapId)
VALUES
(@Id, @UserKey, @CreateTime, @Feature, @UserType, @MapId)";
var id = Guid.NewGuid();
conn.Execute(sql,
new
{
Id = id,
UserKey = id.ToString(),
CreateTime = DateTimeOffset.Now,
Feature = new Point(122, 25) { SRID = 4326 },
UserType = 1,
MapId = new Guid("56DD6AA3-63C1-4CC2-8045-AAEA00C31B42")
});
var data = conn.Query<Coordinate>("SELECT TOP 10 Id, Feature.Serialize() AS Feature FROM Coordinates");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment