Why is this foreach loop stopping early?

烈酒焚心 提交于 2019-12-12 00:35:17

问题


I am trying to pull project information from the AtTask/WorkFront site. The foreach loop that I am using stops looping at 100 projects every time.

JToken projects = client.Search(ObjCode.PROJECT, new { groupID = userGroupID });
foreach (var j in projects["data"].Children())
{
    Console.WriteLine("# " + counter + " Name: {0}", j.Value<string>("name")); 
    counter++;
}

This produces names just as I need it to, except that the loop always stops short. The code for this loop came directly from the WorkFront developer site (https://developers.workfront.com/api-docs/code-samples/).

Is this caused by the WorkFront API having a call limit or is there a mistake in the code? What can I do to fix this issue?


回答1:


From the documentation:

Default Number of Results 100 If no limit is specified in the query filter (ie, $$LIMIT), the result will contain no more than 100 primary objects. See the example below for instructions on how to use the $$LIMIT in your query filter.




回答2:


Via the WorkFront docs...

If no limit is specified in the query filter (ie, $$LIMIT), the result will contain no more than 100 primary objects. See the example below for instructions on how to use the $$LIMIT in your query filter.

https://developers.workfront.com/api-docs/#Guidelines



来源:https://stackoverflow.com/questions/31572684/why-is-this-foreach-loop-stopping-early

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!