profou
profou

Reputation: 217

STIntersects between SqlGeography types in a condition IF

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

Answers (2)

displayName
displayName

Reputation: 14379

Matthew Evans has given complete answer. Here is same answer phrased differently.

Upvotes: 0

Matt Evans
Matt Evans

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

Related Questions