Monday, October 28, 2013

C# Create DbGeography Point in Entity Framework

public DbGeography GeoPoint(Double latitude, Double longitude)
{
//Assembly Microsoft.SqlServer.Types.dll, v11.0.0.0
       SqlGeography sqlGeo = SqlGeography.Point(latitude, longitude, 4326);

       //Assembly System.Data.Entity.dll, v4.0.0.0
       DbGeography dbGeom = DbGeography.FromText(sqlGeo.ToString(), 4326);

       return dbGeom;

}

No comments:

Post a Comment