为什么这个foreach循环会提前停止? [英] Why is this foreach loop stopping early?
问题描述
$ b $ pre $
JToken projects = client.Search(ObjCode.PROJECT,新{groupID = userGroupID});
foreach(var j in projects [data]。Children())
{
Console.WriteLine(#+ counter +Name:{0},j.Value< ;字符串>( 名称));
counter ++;
$ b $ p
$ b这就产生了我所需要的名称,除了循环总是停止短。此循环的代码直接来自WorkFront开发人员网站( https://developers.workfront .com / api-docs / code-samples / )。
这是由于WorkFront API的调用限制或者是否存在错误码?我可以做些什么来解决这个问题?
解决方案 From 文档:
lockquote
默认结果数目100如果没有限制在查询
过滤器(即$$ LIMIT)中指定,结果将包含不超过100个主
对象。请参阅下面的示例以获取有关如何在查询过滤器中使用
$$ LIMIT的说明。
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?
解决方案 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.
这篇关于为什么这个foreach循环会提前停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!