tags:

views:

26

answers:

2

Using TFS SDK, I am querying workitems using WorkItemStore.Query:

WorkItemCollection workItems = WorkItemStore.Query("SELECT ID from workitems");

foreach(WorkItem wi in workItems)
{
    string Id = wi.Id;
    foreach(Attachment attachment in wi.Attachments)
    {
        Console.Write(attachment.Uri.OriginalString); //SLOW
    }
}

Accessing items from the collection is too slow. Is it talking to the TFS server everytime I access a WorkItem member? Is there a way to construct my query in such a way that it will get all the fields that I need in one go?

Problem is, the TFS server is located off-shore, and that's why it's slow. Querying stuff en-masse makes it a lot faster.

EDIT: I can't query the attachments field. "attachments" is not a valid field.

A: 

Well, your query specifies that it only needs to grab the ID from the workitems. As you asked, I would suspect that requesting all the information that you want would be more efficient, as it would need to gather all of it before it returned.

MasterMax1313
A: 

Your query does not fetch attachments. Each wi.Attachments call will make another query to get the data.

AZ