How is the @Me TFS query variable derived?

谁说我不能喝 提交于 2019-12-11 03:38:21

问题


Does anyone know exactly how this value is derived?

For half our team it seems to be "FistName.LastName". For the other half it is "FirstName LastName"...

I thought I would be able to find this out in five seconds of googling but all I can find are vague statements that say "the current user" or "the current users alias".

The MSDN article about query variables here describes it as being the current users alias but I have no idea what that means....


回答1:


When running a query in Visual Studio, TFS is building an SQL query for it. If you run SQL Server Profiler on the Tfs_DefaultCollection database you should notice a similar query:

exec sp_executesql N'set nocount on
declare @PersonId as int
declare @rebuildOK as int
declare @PersonName as nvarchar(255)declare @userSid as nvarchar(256)
set @userSid=@P1
exec @rebuildOK=dbo.RebuildCallersViews @PersonId output,@P1
if @rebuildOK<>0 return
DECLARE @AsOfUtc DATETIME; SET @AsOfUtc=@P2
DECLARE @Ids TABLE (Id INT NOT NULL)
INSERT INTO @Ids SELECT X.ID FROM (
SELECT @P3 AS ID
UNION ALL
SELECT @P4 AS ID
) as X

join  dbo.[WorkItemsLatestUsed] RL
on X.ID = RL.[System.Id]
where RL.[System.AreaID] not in
(
    select V.BelowID
    from dbo.[GetInverseUserPermissions](@userSid,1) V
)
option (loop join)


SELECT I.[System.Id],I.[System.Rev],I.[System.AreaId],I.[System.IterationId],I.[System.WorkItemType],I.[System.AssignedTo]
FROM @Ids Ids
JOIN [dbo].[WorkItemsAsOf] I with (nolock)
ON I.[System.Id] = Ids.[Id]
    AND I.[System.ChangedDate] <= @AsOfUtc
    AND @AsOfUtc < I.[System.RevisedDate]
OPTION (LOOP JOIN)
set nocount off
',N'@P1 nvarchar(4000),@P2 datetime,@P3 int,@P4 int',@P1=N'S-1-5-21-3698201826-3150490006-716737659-1107',@P2='2012-03-24 19:48:09.707',@P3=1266,@P4=1587

Note the use of dbo.RebuildCallersViews stored procedure which in turn serves the @userSid variable and ultimately the temporary I.[System.AssignedTo] column. Stored procedures in TFS database are protected so I couldn't decipher what's going beyond that.



来源:https://stackoverflow.com/questions/9838733/how-is-the-me-tfs-query-variable-derived

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!