Reputation: 2205
In f# I'm attempting create a SqlGeography type and save it to a record. When SubmitChanges is called at runtime, it returns the following error message.
Also, I am using LinqPad if that matters.
InvalidCastException: Could not convert from type 'Microsoft.SqlServer.Types.SqlGeography' to type 'Microsoft.SqlServer.Types.SqlGeography'.
let dc = new TypedDataContext()
let lat = 45.523062
let long = -122.676482
let srid = 4326
let property = query {
for prop in dc.Property do
where (prop.PropertyID = 15957)
select prop
exactlyOne
}
let sqlGeogBuild = new SqlGeographyBuilder()
sqlGeogBuild.SetSrid(srid)
sqlGeogBuild.BeginGeography(OpenGisGeographyType.Point)
sqlGeogBuild.BeginFigure(lat, long)
sqlGeogBuild.EndFigure()
sqlGeogBuild.EndGeography()
property.Location <- sqlGeogBuild.ConstructedGeography.MakeValid()
//property.Dump()
dc.SubmitChanges()
Upvotes: 3
Views: 404
Reputation: 5341
This question was asked on Apr 2016 and is using SQLProvider that added the support for MSSQL geography types on May 2020.
Upvotes: 0