Connect to from code


  • Hi

    First of all: What a nice piece of work you have done so far with TFS. I'm impressed!

    Would it be possible to connect to the "WorkItem database" via a custom .Net application. We're currently pulling information from our internal TFS into our ERP-system and would like to be able to do the same with tfspreview. Is that possible and do you have any documentation on how to access the web service?



    Thursday, October 20, 2011 1:17 PM


  • Hi Casper and Trevor,

    I have been doing this for a while. If i understand your question correctly you want to consume the work item data through .net code so that you can make use of it in your custom application. 

    The TfsService allows you to use the TFS API against it. I'll show this to you with an example,

    1. You need to download the TFS SDK, the TFS 2010 SDK works with TFS Azure. My tfs preview collection is the TFS URI is "" you can see this blog post on where to find the uri (step 5) (this also has a link to the download for tfs sdk)

    2. Connect to TFS programmatically and use the work item store service. 


    var tfs =
                        new Uri(""));
                var service = tfs.GetService<WorkItemStore>();

    3. The work item store service class makes all work item operations available to you. See this link for more details,


    now if you wanted to query a work item by id, you could do something like below,


    public WorkItem GetWorkItemDetails(int id)
                var tfs =
                        new Uri("https://tfs2010:8080/defaultcollection"));
                var service = tfs.GetService<WorkItemStore>();
                return service.GetWorkItem(id);


    4. You could take steps forward and build wiq both flat and tree, links in code and execute them. I have several blog posts on using the TFS API, all of these have been build against the TFS Azure.

    If you have any follow up questions, please don't hesitate to add to the thread.

    Cheers, Tarun 

    Please remember to mark the replies as answers if they help.

    Tarun Arora


    Blog:  Subscribe in a reader

    Thursday, October 20, 2011 6:52 PM

All replies