Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / DevOps / TFS

TFS API: Using LINQpad to Query TFS

5.00/5 (2 votes)
13 Sep 2011CPOL1 min read 16.6K  
TFS API: Using LINQpad to query TFS

In this blog post, I’ll be showing you how to query TFS using LINQpad.

1. Download LINQpad

Those who are familiar with LINQpad know its benefits and ease of use. I would urge others to try it. You can download LINQpad and read more about it from here.

2. Download TFS SDK

I have a blog post on where and how to download the TFS SDK from here.

3. Querying TFS using LINQpad

image

  • Open LINQpad

    image

  • Select Query Properties by selecting Query from menu bar and clicking on ‘Query Properties’. You could also press F4 to get to the query properties.

    image

  • Add reference to TFS SDK DLLs, click ‘Browse’ and navigate to ‘C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0’ and select the following references and click open.

    image

    image

  • At this point, you should be able to see the following in ‘Additional References’:

    image

  • Click on Additional Namespace import and enter the following namespaces:
    • Microsoft.TeamFoundation.Client
    • Microsoft.TeamFoundation.VersionControl.Client
  • Change the Language to C# Program, the query window should look like below now:

    image

  • Let's connect to the TFS server using the TFSTeamProjectConnectionFactory:
    C#
    void Main()
    {
        var tfs = TfsTeamProjectCollectionFactory
                    .GetTeamProjectCollection
    		(new Uri("https://tfs.codeplex.com/tfs/tfs34"));
        tfs.EnsureAuthenticated();
        tfs.Dump();
    }
  • See the results window, LINQpad gracefully dumps the results for you, no worrying about parsing or binding the results.

    image

Doesn’t that make querying TFS for information so much easier?Image 9

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)