Answered by:
Work Item linked Query not working

Question
-
Hi Team,
I have using WorkItemLink Query to get results of a below linked query, but i get zero results.
Below is the query that i executed from TFS, copied the query to .wiq file. Got the query by opening the .wiq file using notepad.
query = new Query(_store,
string.Format("SELECT [System.Id], [System.Links.LinkType], [System.WorkItemType], [System.Title] FROM WorkItemLinks WHERE([Source].[System.TeamProject] = 'Global IT' AND [Source].[System.WorkItemType] = 'Bug') And ([System.Links.LinkType] & lt; > '') And([Target].[System.WorkItemType] = 'User Story' OR [Target].[System.WorkItemType] = 'Test Case') ORDER BY[System.Id] mode(MustContain)"));var workitems = query.RunLinkQuery();\
Query that i am using is a linked query to get Bugs of Project Global that has linked userstories and testcases. this query results record from visual studio when executed manual but does
not return results from above C# code.Can you please let me know if i am missing anything.
Thanks,
Thursday, November 30, 2017 6:55 AM
Answers
-
Hi!
No. Link Query contains only ids of linked work items. You have to use WorkItemStore.GetWorkitem(ID) to get full information about work item.
- Marked as answer by Anil kumarGMicrosoft employee Monday, December 4, 2017 9:01 AM
Friday, December 1, 2017 9:03 AM
All replies
-
Hi!
You have to change:
[System.Links.LinkType] & lt; > ''
to
([System.Links.LinkType] <> '')
- Proposed as answer by Alexandr ShamrayMVP Friday, December 1, 2017 9:04 AM
Thursday, November 30, 2017 9:58 AM -
This is amazing. My query works perfectly fine with above change.
Appreciate your help,
When I use link query I am getting only these four columns
Even though I used WorkItemType and Title, I get only SourceId, LinkType, TargetId for
WorkItemLinkInfo[] temp = query.RunLinkQuery();
is there anyway to get title , workitem type and another values from same LinkQuery ?
Friday, December 1, 2017 4:46 AM -
Hi!
No. Link Query contains only ids of linked work items. You have to use WorkItemStore.GetWorkitem(ID) to get full information about work item.
- Marked as answer by Anil kumarGMicrosoft employee Monday, December 4, 2017 9:01 AM
Friday, December 1, 2017 9:03 AM