0

我正在编写一个可以运行查询的 TFS 扩展。正如我所见,在使用 TFS API 运行查询之前,必须替换所有定义的变量。

我在这里查看了默认的 TFS 变量,除了@Today变量,我可以理解所有变量。

@Today变量的主要问题是您可以向其添加运算符,例如:

[来源].[Microsoft.VSTS.Common.ActivatedDate] = @today - 7

我是否需要用当前日期(和时间?)替换变量并让查询引擎进行数学运算,还是应该在将其传递给查询引擎之前进行数学运算?

4

1 回答 1

3

您不需要替换@Today任何内容,只需“按原样”运行查询即可。

例如在Linqpad中运行以下命令:

using (var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(CollectionAddress)))
{
    tfs.EnsureAuthenticated();
    var server = tfs.GetService<WorkItemStore>();

    server
    .Query("select * from WorkItems where System.CreatedDate > @today - 1")
    .Cast<WorkItem>()
    .Select(wi => new { wi.Id, wi.CreatedDate, })
    .Dump(); //This is a http://LinqPad.net extension method.
}

返回自今天早上以来在我的 TFS 集合中记录的所有工作项。

工作项查询语言 (WIQL) 解析器必须为您处理这些事情。

于 2012-09-26T18:57:31.813 回答