我使用SqlGeography类型。
STIntersects函数的以下用法是否有所不同:
this.Location.STIntersects(another.Location)和
this.Location.STIntersects(another.Location).Value和
this.Location.STIntersects(another.Location).Equals(1)我得到了不同的结果。
发布于 2015-10-29 21:27:02
问题是SqlIntersects方法返回的不是布尔值,它返回的是SqlBoolean结构
假设您的地理位置相交,我将假设您获得以下值:
this.Location.STIntersects(another.Location) => true
this.Location.STIntersects(another.Location).Value =>返回SqlBoolean返回值的值比例=> true
this.Location.STIntersects(another.Location).Equals(1) =>将SqlBoolean结构与值1进行比较,并返回false
发布于 2015-10-29 22:24:17
马修·埃文斯给出了完整的答案。这是相同的答案,但措辞不同。
如果两个位置相交,则
Location.STIntersects(another.Location)返回一个包含true的SqlBoolean,否则它返回一个false.Location.STIntersects(another.Location).Value,返回true或false类型为System.Boolean而不是SqlBoolean above.Location.STIntersects(another.Location).Equals(1)返回"。因此,它将始终以您正在比较的方式返回false。https://stackoverflow.com/questions/33415004
复制相似问题