Reputation: 95
How get a WorkItem collection by querying WorkItem store with the field of their revision.
WorkItemCollection WIC = WIS.Query(
" SELECT * " +
" FROM WorkItems " +
" WHERE [System.TeamProject]='project1' AND [Work Item Type]='Bug' AND [System.Revision.ChangedBy]=@Me ORDER BY [System.WorkItemType], [System.Id]");
I need a work item collection like that , but the error generated at [System.Revision.ChangedBy]
Is there any way to get a work item collection that their revisions changedby=@me
i.e- if one workitems's revision has at least one record that changed by me, I need it in my workitem collection
I tried in many ways but not found a solution yet.
I tried by Getting all work items and then try to find revision values of each work items but it take a lot time to execute. That's why I need to filter them when getting workItem collection,
thanks
Upvotes: 0
Views: 1775
Reputation: 29976
No, you cannot use "System.Revision.ChangedBy" in WIQL script. And you cannot use "@me" macros in API either, it can only be used in TFS Web Portal or Team Explorer.
The way to achieve the feature you want is just as what you say, get the work items by the WIQL first and then check the revision for all of them. Some code for your reference:
string tfsurl = "http://xxxxxxxxxx/";
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(tfsurl));
WorkItemStore wis = ttpc.GetService<WorkItemStore>();
WorkItemCollection wic = wis.Query(" SELECT * " + " FROM WorkItems " + "WHERE [System.TeamProject]='GitBuildRelease' AND [Work Item Type]='Bug'");
List<WorkItem> wies = new List<WorkItem> { };
foreach (WorkItem wi in wic)
{
foreach (Revision rev in wi.Revisions)
{
if (rev.Fields["Changed By"].Value.ToString() == "yourdisplayname")
{
wies.Add(rev.WorkItem);
break;
}
}
}
Upvotes: 3