Work Item Tracking Architecture

The Work Item Tracking Architecture defines a team project's WorkItem types, queries, and WorkItem instances.

Hierarchy of the Work Item Tracking Architecture

The Work Item Tracking Architecture is a hierarchical structure. A server contains a WorkItemStore. A WorkItemStore contains Projects. Projects contain WorkItemTypes, and so on.

The architecture can be viewed like this:


    The server that stores the Team Foundation database.

    TeamFoundationServer tfs =



            The database that stores all Projects and related data.

            WorkItemStore store =



                    Describes the overall Project.

                    foreach (Project project in store.Projects)


                        Console.WriteLine("Project: " + project.Name);



                            The types of WorkItems that exist within this Project ("Bug", "Task", "Scenario", and so on.).

                            foreach (WorkItemType workItemType in project.WorkItemTypes)


                                Console.WriteLine("WorkItemType: " + workItemType.Description);


                            As soon as you know a WorkItemType within a Project, you can create WorkItems of that


                            Each WorkItemType has a FieldDefinitionCollection specific to this WorkItemType. This is a

                            subset of the FieldDefinitions found at the WorkItemStore level.

                            foreach (FieldDefinition fieldDefinition in workItemType.FieldDefinitions)


                                Console.WriteLine("FieldDefinition:" + fieldDefinition.Name);


                            The FieldDefinitionCollection holds the FieldDefinition for each field in this

                            WorkItemType (for example, Title, Activated Date, Activated By, Priority, and so on).


                            StoredQueries specific to this Project.

                            foreach (StoredQuery storedQuery in project.StoredQueries)


                                Console.WriteLine("StoredQuery: " + storedQuery.Name);



                    Description for all fields used in all Projects on this WorkItemStore.

                    foreach (FieldDefinition fieldDefinition in store.FieldDefinitions)


                        Console.WriteLine("FieldDefinition:" + fieldDefinition.Name);


                        Various parameters of each field are:

                            FieldType: Integer, String, DateTime, and so on.





                            AllowedValues: A list of permissible values, such as "Active", "Fixed", "Postponed",

                            "Won't Fix", "Closed".


                    Link types available to all Projects on this WorkItemStore

                    Links can link to things like "Related WorkItem", "Source Code File", "Test Result", and so on


WorkItems are defined by a WorkItemType.

WorkItems belong to a Project.

WorkItems have

Fields, which are stored in a FieldCollection, as defined by the WorkItem's WorkItemType.

Links, which are stored as a LinkCollection. Links can be Hyperlinks, RelatedLinks, and ExternalLinks.

Attachments are stored as an AttachmentCollection.

Revision history: Each change to a WorkItem creates a new revision of that WorkItem. You can retrieve all revisions of a WorkItem from the database.

How to Get WorkItems

You can retrieve the WorkItems by ID:

WorkItem workItem1 = workItemStore.GetWorkItem(id);
WorkItem workItem2 = workItemStore.GetWorkItem(15407);

You can retrieve the WorkItems by URI:

WorkItem workItem3 = workItemStore.GetWorkItem(uri);
WorkItem workItem4 = workItemStore.GetWorkItem("vstfs:///WorkItemTracking/WorkItem/15407");

You can get the previous revisions of a WorkItem by ID or URI, plus DateTime:

WorkItem workItem5 = workItemStore.GetWorkItem(id, new DateTime(2006, 4, 17));
WorkItem workItem6 = workItemStore.GetWorkItem(uri, new DateTime(2006, 6, 30));

You can get the previous revisions of a WorkItem by ID or URI, plus revision number:

WorkItem workItem7 = workItemStore.GetWorkItem(id, 1);
WorkItem workItem8 = workItemStore.GetWorkItem(uri, 5);

See Also


How to: Get a WorkItem

How to: Get a Previous Revision of a WorkItem


Ways to Get a WorkItem

Essentials of Work Item Tracking Object Model