Created
February 13, 2020 10:27
-
-
Save lettucebo/12076a87afdc0c744c25fa9da4e7c86a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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