Getting WorkItems by Project Name from TfsWorkItemTracking database

Hi all,

I would like to retrieve the list of work items from TfsWorkItemTracking database because of some reason, The only why i'm able to find out is to get all the Areas from TreeNodes table and then get WorkItems based on Area but it involves recursively retrieval of Areas, is there any other path to it?

why i'm saying project name in the title coz i wanted to retrieve them by project, and which is now i know i can do it via top most area from TreeNodes as its same as the project name and u cant rename it as well :).

regards
faraz

[565 byte] By [Faraz_Ahmed] at [2007-12-24]
# 1

Hello Faraz,

I am assuming you are using WorkItem Object Model to get the work items. One easy way to get the work items in each project would be

WorkItemStore store =newWorkItemStore("<Server_Name>");

string query ="SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.TeamProject] = @project";

System.Collections.Hashtable context =new System.Collections.Hashtable();

context.Add("project","<project_name>");

store.Query(query, context);

If you want it based on a single project then it can be much more easy, just put the project name in place of @project, it would look like

WorkItemStore store =newWorkItemStore("<Server_Name>");

string query ="SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.TeamProject] = '<Project_Name>'";

store.Query(query, context);

Hope this helps,

SmithaSSaligrama at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 2
thanks for the reply, but no as i mentioned i'm retrieving it from TfsWorkItemTracking database, so i'v to use sql for that coz i'v to update one field of all the workitems of a particular proj coz of some reason..i'v already done it in warehouse but workitem database is remaining and after analyzing the tables, i'm not able to figure out except the way i'v mentioned in my last post.. so i'm looking something straight..

regards
faraz

Faraz_Ahmed at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 3

Hi,

This is a worst pratice, you should consider the TFS Databases like "Black Box". Data Schema could be updated in the futures versions and a lot of your code would not work anymore.

You should only ask TFS server using the API.

mathieu.szablowski at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 4
I totally agree with you, and i know it very well.. but the situation i'v, its first of all one time issue.. 2ndly its just a one field i wana change which is just a value type.. if u wana know i can explain u the scenario why i wana do this...but if there is no solution other then recursive query.. :)

regards
faraz

Faraz_Ahmed at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 5
Yes, can you explain your scenario on why you need to access database directly to update field values? You can update fields using our object model for all work items in server and that is the approach we recommend.
NarenDatha-MSFT at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 6
hmm, the change is just one time.. its in a value type column, so i thought instead of writing code i shuld just update the column values thats it.. the column is our own custom one with combo selected values, and we have updated value list, so wanted to update existing project's workitmes. :)

regards

Faraz_Ahmed at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 7

Updating values in database is tricker than it seems. Here are some questions to think about: If you do update the value, do you expect it to be updated only on latest revision or on all old revisions? If you update it on specific existing revision, during auditing it seems as if the actual user who created the revision added that value when in fact an admit directly changed the db. Sometimes we do cache strings and place ids in table to reduce data size, in which case it is tricky to get the string id. For various reasons like this, changing data directly is discouraged and will void support.

You can update fields of many items easily by exporting into excel and then bulk changing field values, it requires no coding.

NarenDatha-MSFT at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 8
well agreed, this is the only fear i had as well, coz i explored workitemtracking database and it had lots of different things in it.. but yeah i'v updated all the versions "Latest,Are and Were", and before that i did checked it on our RnD TFS, it worked fine so i did in the production server as well.. anyway.. i know its bad.. but its done now :) .. but yeah..i totally forgot excel as TFS client.. and found it the easiest way to do it.. anyway thanks alot..i'v marked ur last reply as answer :)
Faraz_Ahmed at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...

Visual Studio Team System

Site Classified