WorkItemStore.Query("YourQuery") Getting Error when fetching data from TFS in .Net c# -


i'm getting problem when i'm fetching data vstf server using following code. can me how can extend collection size or else achieve more records.

uri tfsuri = new uri(uri);  tfsteamprojectcollection tfs = new tfsteamprojectcollection(tfsuri, tfscredential); workitemstore workitemstore = new workitemstore(tfs); var query = workitemstore.query(projectquery); 

i'm getting error in last row of code. please follow following error given below:

processing team project "[myproject]" error occurred while processing team project "[myproject]": vs402337: number of work items returned exceeds size limit of 50000. change query return fewer items. microsoft.teamfoundation.workitemtracking.client.verbatimmessageexception: vs402337: number of work items returned exceeds size limit of 50000. change query return fewer items. ---> system.web.services.protocols.soapexception: vs402337: number of work items returned exceeds size limit of 50000. change query return fewer items. @ microsoft.teamfoundation.workitemtracking.proxy.retryhandler.handlesoapexception(soapexception se) @ microsoft.teamfoundation.workitemtracking.proxy.workitemserver.queryworkitemcount(string requestid, xmlelement psquery, boolean usemaster, int32& count, datetime& asofdate, metadatatablehaveentry[] metadatahave, string& dbstamp, imetadatarowsets& metadata) @ microsoft.teamfoundation.workitemtracking.client.workitemstore.queryworkitemcount(string requestid, xmlelement queryxml, datetime& asof) --- end of inner exception stack trace --- @ microsoft.teamfoundation.workitemtracking.client.workitemstore.queryworkitemcount(string requestid, xmlelement queryxml, datetime& asof) @ microsoft.teamfoundation.workitemtracking.client.query.runcountquery(string requestid) @ microsoft.teamfoundation.workitemtracking.client.workitemstore.querycount(string wiql, idictionary context) @ teamprojectmanager.modules.workitemconfiguration.workitemtypes.workitemtypesviewmodel.<>c__displayclass82_0.b__0(object sender, doworkeventargs e) in c:\users\jelled\desktop\code\tfsteamprojectmanager\repo\teamprojectmanager.modules.workitemconfiguration\workitemtypes\workitemtypesviewmodel.cs:line 169 retrieved 22 work item types

you have 2 ways fix that:

  • add query conditions return fewer items error message mentioned.

    eg:

    select * workitems [system.teamproject] = @project , [system.state] = ‘active' , [system.assignedto] = ‘joselugo'

  • split groups return them separately. there sample retrieving list of work item types reference: (see github details.)

    // there vso limit of query returning 20,000 results. split groups of 10,000 items maximum. var results = new list<workitemreference>(); var counter = 10000; var moreresults = true; while (moreresults) { list<workitemreference> currentresults = this.witclient.querybywiqlasync(new wiql { query = $"select system.id workitems system.teamproject = '{project}' , {customquery} , system.id >= {counter - 10000} , system.id < {counter}"}).result.workitems.tolist();

    if (currentresults.count == 0) {     // verify there no more items     try     {         results.addrange(this.witclient.querybywiqlasync(new wiql         {             query = $"select system.id workitems system.teamproject = '{project}' , {customquery} , system.id >= {counter}"         }).result.workitems.tolist());          moreresults = false;     }     catch (exception e)     {         if (e.tostring().contains("vs402337"))         {             // there still more results, increment , try again.         }         else         {             throw;         }     } } else {     results.addrange(currentresults); }  counter += 10000; 

    }


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -