sqlgeography

Error getting value from 'WellKnownValue' on 'System.Data.Entity.Spatial.DbGeography

早过忘川 提交于 2019-11-30 23:17:03
I am using the DbGeography-Type within a SinglePageApplication (with breeze and angular). Now when using the Data with the DbGeography-Type (readOnly) there is no problem. As soon as I save an entity which has a property of DbGeography-Type I get the following error: Error getting value from 'WellKnownValue' on 'System.Data.Entity.Spatial.DbGeography' When the data is serialized to JSON (with newtonsoft JSON.NET or is it ODATA/WebAPI?), the DbGeography gets serialized correctly but the property "WellKownValue" is called "Geography". This is also reflected in the MSDN-Documentation: https:/

'The specified input does not represent a valid geography instance' exception when using SqlGeographyBuilder

北城以北 提交于 2019-11-30 23:11:11
I've written a small application that reads in from a series of KML files and then converts them into the Microsoft.SqlServer.Types.SqlGeography type using the following code: private SqlGeography CreateGeographyFromKML( string kml, bool debug ) { // use SqlGeographyBuilder to help create the SqlGeography type var geographyBuilder = new SqlGeographyBuilder(); // Get co-ordinates var xml = XDocument.Parse(kml); var df = xml.Root.Name.Namespace; XElement coordinates = xml.Descendants(df + "coordinates").Single(); // set the Spatial Reference Identifiers that will used to create the point

Convert SQL geography to C#

梦想与她 提交于 2019-11-29 06:03:10
What is the C# equivalent of this geospatial T-SQL code? DECLARE @g geography; DECLARE @h geography; SET @g = geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326); SET @h = geography::Point(47.653, -122.358, 4326) SELECT @g.STIntersects(@h) I am trying to find a point in a polygon using the SqlGeometry data type -- and can with the above T-SQL; but I do not understand how to achieve equivalent C# code. Try this: public bool OneOffSTIntersect() { var g = Microsoft.SqlServer.Types.SqlGeography.STGeomFromText( new System

Convert SQL geography to C#

扶醉桌前 提交于 2019-11-27 23:31:59
问题 What is the C# equivalent of this geospatial T-SQL code? DECLARE @g geography; DECLARE @h geography; SET @g = geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326); SET @h = geography::Point(47.653, -122.358, 4326) SELECT @g.STIntersects(@h) I am trying to find a point in a polygon using the SqlGeometry data type -- and can with the above T-SQL; but I do not understand how to achieve equivalent C# code. 回答1: Try this:

Is it possible to use SqlGeography with Linq to Sql?

半城伤御伤魂 提交于 2019-11-26 14:12:18
问题 I've been having quite a few problems trying to use Microsoft.SqlServer.Types.SqlGeography . I know full well that support for this in Linq to Sql is not great. I've tried numerous ways, beginning with what would the expected way (Database type of geography , CLR type of SqlGeography ). This produces the NotSupportedException , which is widely discussed via blogs. I've then gone down the path of treating the geography column as a varbinary(max) , as geography is a UDT stored as binary. This