TFS Api - Error in query with DateTime

4

I'm trying to make a query using the TFS API where I need to get all the WorkItems that have been edited from a certain date, however I get the following error:

  An unhandled exception of type   'Microsoft.TeamFoundation.WorkItemTracking.Client.ValidationException'   occurred in Microsoft.TeamFoundation.WorkItemTracking.Client.dll

     

Additional information: You can not supply a time with the date when   running a query using date precision. The error is caused by «[Changed   Date] > '09 / 11/2015 14:12:43 '.

I need to query using the date and time, but I think this is what is causing the error, below the code I am using for the query:

var query = "SELECT [ID] FROM WorkItem WHERE [Work Item Type] = '{0}' AND [Changed Date] > '{1}'";
var workItens = GetWorkItemStory().Query(string.Format(query, WORKITEM_TYPE, dataBase));
return (from WorkItem workItem in workItens select workItem).ToList();

Any idea what I can do to solve the problem?

    
asked by anonymous 09.11.2015 / 17:32

1 answer

2

I solved using a "POG" with linq.

When I get the items from Api, I'm looking for everyone with the date equal or bigger than I want, without considering the time, then I'll make a linq to search only from the time I want. It's not something nice but it's functional.

var query = "SELECT [ID] FROM WorkItem WHERE [Work Item Type] = '{0}' AND [Changed Date] >= '{1}'";
var workItens = GetWorkItemStory().Query(string.Format(query, WORKITEM_TYPE, dataBase.ToShortDateString()));
return (from WorkItem workItem in workItens where workItem.ChangedDate > dataBase select workItem).ToList();

But if someone can explain the reason and a more "beautiful" solution, I will accept it as an answer.

    
09.11.2015 / 18:55