我在Dynamics CRM中有1,072,369
个联系人记录。我需要检索它们然后进行操作。现在,在检索时遇到了以下异常
无法分配1073741824字节的托管内存缓冲区。可用内存量可能很低。
我将时间跨度增加到10分钟,但没有运气。
我正在寻求您的善意建议/帮助解决它。以下是我的代码段。
ColumnSet col = new ColumnSet();
col.AddColumns("new_name", "accountid", "contactid");
//get Related Record
QueryExpression qe = new QueryExpression
{
EntityName = entity,
ColumnSet = col,
Criteria = new FilterExpression
{
Conditions = {
new ConditionExpression("accountid",ConditionOperator.NotNull),
new ConditionExpression("statecode",ConditionOperator.Equal,0)
}
}
};
EntityCollection ec = sp.RetrieveMultiple(qe);
答案 0 :(得分:0)
您有1,072,369
,所以我建议您批量检索这些记录。如果有助于检索记录,您可以尝试使用以下代码进行尝试。
QueryExpression qe = new QueryExpression
{
EntityName = entity,
ColumnSet = col,
Criteria = new FilterExpression
{
Conditions = {
new ConditionExpression("accountid",ConditionOperator.NotNull),
new ConditionExpression("statecode",ConditionOperator.Equal,0)
}
}
};
qe.PageInfo = new PagingInfo();
qe.PageInfo.PagingCookie = null;
qe.PageInfo.PageNumber = 1;
qe.PageInfo.Count = 500;
while (true)
{
EntityCollection results= sp.RetrieveMultiple(qe);
if (results.Entities != null)
{
}
// 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;
}
}
请参阅此处了解详情:
https://msdn.microsoft.com/en-us/library/gg327917.aspx Page large result sets with QueryExpression