The Work Item Object Model sample includes seven different projects, each of which creates one console application. Each console application shows the individual parts of the Work Item Object Model.
Attachments
Linking
Query
StoredQuery
WorkItemEdit
WorkItemNew
WorkItemType
You will find two solution files. One is C# and the other is Visual Basic. Each language offers the same functionality.
To build all the projects
In the Sample Browser, right click C# Example.UsingTheWorkItemObjectModel and choose Open in VS.
Press F5 to build the sample.
To see each console application
At the command prompt, type the name of the console application you wish to run.
Attachments
Linking
Query
StoredQuery
WorkItemEdit
WorkItemNew
WorkItemType
Requirements
Team Foundation Server installation and the name of the server.
A computer that has Visual Studio installed.
A computer that has Team Explorer installed.
Demonstrates
Attachments Project
Main()
Connects to the Team Foundation Server and the WorkItemStore.
Creates a new WorkItem in the first project on the server.
Adds OnFieldChanged to handle the workItem.FieldChanged events.
Adds two attachments, Hello World.txt and Sunset.jpg.
Saves the WorkItem.
Removes the second attachment.
Saves the WorkItem again.
OnFieldChanged()
Displays the field that changed and shows its new value.
OutputAttachments()
Lists the details of each attachment in the specified AttachmentCollection.
GetServer()
Returns the Team Foundation Server name from the environment variable "TEAM_FOUNDATION_SERVER_NAME."
If TEAM_FOUNDATION_SERVER_NAME is not defined, it asks for the server name from the console.
Linking
Main()
Connects to the Team Foundation Server and the WorkItemStore.
Creates a new WorkItem in the first project on the server.