tfs - 如何在 WIQL 的 ms sql 中使用 LIMIT 关键字来查询 TFS 工作项

标签 tfs workitem tfs-workitem tfs-sdk wiql

我正在研究 TFS API,我不知道 TFS API 有任何类似 LIMIT 关键字或没有的东西。我需要它来进行分页。

谢谢

最佳答案

没有什么等同于 SQL LIMIT TFS WIQL 中的关键字,您需要自己实现分页。

一种方法是在第一次访问时检索所有结果,并缓存它们并自己分页。

另一种方法是在每次用户页面时动态构建 WIQL 查询。例如:

  • 运行 WIQL 查询以仅返回与查询匹配的工作项 ID。 SELECT [System.Id] FROM WorkItems WHERE <conditions>
  • 缓存该 ID 列表
  • 将该 ID 列表分成与您的分页大小匹配的组
  • 每次您的用户页面时,通过 ID 明确请求工作项。 SELECT <fields> FROM WorkItems WHERE [System.Id] IN (10,11,12,13,14,15)

  • 根据您要实现的目标,您还应该知道 TFS 工作项跟踪 API 在后台实现了字段值的分页/延迟加载,以最大限度地提高响应时间。您可以通过附加网络嗅探器并在 Visual Studio 中滚动大型工作项查询来了解其工作原理。

    Paging of Field Values想要查询更多的信息:

    You can minimize round trips to the server by selecting all fields that your code will use. The following code makes one round trip for the query and one round trip to return a page of titles every time that a new page is accessed.


    WorkItemCollection results = WorkItemStore.Query(
        "SELECT Title FROM Workitems WHERE (ID < 1000)");
    
    foreach (WorkItem item in results)
    {
        Console.WriteLine(item.Fields["Title"].Value);
    }
    

    If your code accesses a field that you did not specify in the SELECT clause, that field is added to the set of paged fields. Another round trip is performed to refresh that page to include the values of that field.

    关于tfs - 如何在 WIQL 的 ms sql 中使用 LIMIT 关键字来查询 TFS 工作项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14282712/

    相关文章:

    TFS 2010 查询具有多个级别的工作项层次结构

    azure - 如何在 Azure Devops 中的工作项的描述部分中创建本地文件链接?

    templates - 无法编辑新添加的工作项字段

    sync - TFS 2010(又名 Microsoft ALM 2010)Web 服务是否公开\记录

    tfs - 如何删除 VSTS 中的共享步骤

    tfs - 仅在 TFS 构建中出现 NSubstitute 参数匹配器错误

    c# - 在 TFS 待办事项板中按列名称获取工作项

    sql-server - 目标主体名称不正确。无法生成 SSPI 上下文

    json - 是否有任何基于 JSON(或 YAML)的 "time sheet"或 "work log"相关格式用于记录任务所花费的时间?

    visual-studio - TFS 2013 : Get all work items below a certain parent