通过使用sdk和fetch查询我在一个请求中获得了5000条记录,并且获取需要花费太多时间。
请给我一些建议如何使用Android中的获取查询和sdk逐页获取记录。
答案 0 :(得分:0)
不确定Android SDK位,但此处介绍了FetchXML分页:Page large result sets with FetchXML
答案 1 :(得分:0)
您可以尝试使用Linq。看看这里 -
https://msdn.microsoft.com/en-us/library/gg334684.aspx?f=255&MSPPError=-2147217396
答案 2 :(得分:0)
您也可以在Query Expression
中尝试此操作:
Page large result sets with QueryExpression
//使用分页cookie进行查询。 //定义分页属性。 //每页要检索的记录数。
int queryCount = 3;
//初始化页码。
int pageNumber = 1;
//初始化记录数。
int recordCount = 0;
//定义用于检索记录的条件表达式。
ConditionExpression pagecondition = new ConditionExpression();
pagecondition.AttributeName = "parentaccountid";
pagecondition.Operator = ConditionOperator.Equal;
pagecondition.Values.Add(_parentAccountId);
//定义订单表达式以检索记录。
OrderExpression order = new OrderExpression();
order.AttributeName = "name";
order.OrderType = OrderType.Ascending;
//创建查询表达式并添加条件。
QueryExpression pagequery = new QueryExpression();
pagequery.EntityName = "account";
pagequery.Criteria.AddCondition(pagecondition);
pagequery.Orders.Add(order);
pagequery.ColumnSet.AddColumns("name", "emailaddress1");
//将pageinfo属性分配给查询表达式。
pagequery.PageInfo = new PagingInfo();
pagequery.PageInfo.Count = queryCount;
pagequery.PageInfo.PageNumber = pageNumber;
//当前的分页cookie。检索第一页时, // pagingCookie应为null。
pagequery.PageInfo.PagingCookie = null;
Console.WriteLine("Retrieving sample account records in pages...\n");
Console.WriteLine("#\tAccount Name\t\tEmail Address");
while (true)
{
// Retrieve the page.
EntityCollection results = _serviceProxy.RetrieveMultiple(pagequery);
if (results.Entities != null)
{
// Retrieve all records from the result set.
foreach (Account acct in results.Entities)
{
Console.WriteLine("{0}.\t{1}\t{2}", ++recordCount, acct.Name,
acct.EMailAddress1);
}
}
// Check for more records, if it returns true.
if (results.MoreRecords)
{
Console.WriteLine("\n****************\nPage number {0}\n****************", pagequery.PageInfo.PageNumber);
Console.WriteLine("#\tAccount Name\t\tEmail Address");
// Increment the page number to retrieve the next page.
pagequery.PageInfo.PageNumber++;
// Set the paging cookie to the paging cookie returned from current results.
pagequery.PageInfo.PagingCookie = results.PagingCookie;
}
else
{
// If no more records are in the result nodes, exit the loop.
break;
}
}