Reputation: 217
I use the SqlGeography type.
Is there a difference between the following uses of STIntersects function:
this.Location.STIntersects(another.Location)
and
this.Location.STIntersects(another.Location).Value
and
this.Location.STIntersects(another.Location).Equals(1)
?
I get different results.
Upvotes: 1
Views: 170
Reputation: 14379
Matthew Evans has given complete answer. Here is same answer phrased differently.
Location.STIntersects(another.Location)
returns a SqlBoolean with true
in it if the locations intersect otherwise it returns a false
.Location.STIntersects(another.Location).Value
returns true
or false
of type System.Boolean rather than SqlBoolean above.Location.STIntersects(another.Location).Equals(1)
returns "true if object is an instance of SqlBoolean and the two are equal; otherwise, false.". Hence it will always return false the way you are comparing.Upvotes: 0
Reputation: 7575
The problem is that the SqlIntersects method doesn't return a bool, it returns a SqlBoolean structure
Assuming your geographies intersect, I would assume you get the following values:
this.Location.STIntersects(another.Location) => true
this.Location.STIntersects(another.Location).Value => returns value proprerty of SqlBoolean return value => true
this.Location.STIntersects(another.Location).Equals(1) => compares SqlBoolean structure to value 1, and returns false
Upvotes: 1