我开始使用 Microsoft SQL ServerGeography
数据类型。一切都很好,但我遇到了一个小问题。
我首先创建了一个包含 2 列的表(ClientId 实际上不是主要的)路由:(ClientId
)int
和Zone
(geography
)
CREATE TABLE [dbo].[routes]
(
[ClientId] [int] NOT NULL,
[Zone] [geography] NULL,
)
我运行了以下脚本(302624121 是新创建的表):
SELECT
o.id as 'Id', c.name as 'Name', t.name AS 'Type',
c.length AS 'Length'
FROM
sys.sysobjects as o
INNER JOIN
sys.syscolumns AS c ON o.id = c.id
INNER JOIN
sys.systypes AS t ON c.xtype = t.xtype
WHERE
(o.id = 302624121)
瞧,这就是我得到的:
302624121 ClientId int 4
302624121 Zone hierarchyid -1
302624121 Zone geometry -1
302624121 Zone geography -1
该区域已创建 3 次!!!!
接下来,我添加了一个存储过程来从上表中选择数据,其中给定点包含在客户端的地理范围内。
Create proc [dbo].[up_RoutesSelectByGeography]
@ClientId int,
@Zone geography
as
begin
SELECT [ClientId], [Zone]
FROM [dbo].[Routes]
where ClientId = @ClientId and [Zone].STContains(@Zone) = 1
end
我使用过程的 id 运行了以下查询:
SELECT
o.id as 'Id', c.name as 'Name',
t.name AS 'Type', c.length AS 'Length'
FROM
sys.sysobjects as o
INNER JOIN
sys.syscolumns AS c ON o.id = c.id
INNER JOIN
sys.systypes AS t ON c.xtype = t.xtype
WHERE
(o.id = 334624235)
而且我总是为同一个变量获得 3 种类型:
334624235 @ClientId int 4
334624235 @Zone hierarchyid -1
334624235 @Zone geometry -1
334624235 @Zone geography -1
这个问题给我带来了一个问题,因为我无法用变量映射字段名称,因为我三次获得相同的变量名称。
对正在发生的事情有任何启示吗?哪些变量映射到我的 c#?