2

正如我从谷歌搜索中了解到的,MSCRM 2011 最多检索 5000 个实体,但我希望我的所有实体都来自营销列表。正如网上所写,在 HKLM\Software\Microsoft\MSCRM 上创建“TurnOffFetchThrottling”字段并将值设置为 1 可以解决此 5000 限制问题(此外,我在注册表中添加了 MaxRowsPerPage 字段并将其值设置为大于 5000,但它也不起作用)。我试过了,我得到了 System.OutOfMemory Exception 错误。顺便说一句,当我删除“”并获得 id 属性代码时效果很好,但我需要所有属性。这是我的 fetchxml 代码:

enter code here
string fetchXml = "<fetch mapping='logical' >"
                  + "<entity name='" + entityType.LogicalName + "'>"
                    + "<all-attributes />"
                    + "<link-entity name='listmember' to='" + entityType.LogicalName + "id" + "' from='entityid'>"
                        + "<filter>"
                          + "<condition attribute='listid' operator='eq' value='" + chosenMarketingListGuid + "'/>"
                        + "</filter>"
                    + "</link-entity>"
                  + "</entity>"
                + "</fetch>";

我又尝试了一件事,我将 fetchxml 更改为:

enter code here
string fetchXml = "<fetch mapping='logical' >"
                  + "<entity name='listmember'>"
                    + "<all-attributes />"
                        + "<filter>"
                          + "<condition attribute='listid' operator='eq' value='" + chosenMarketingListGuid + "'/>"
                        + "</filter>"
                  + "</entity>"
                + "</fetch>";

正如所见,我尝试仅检索成员列表而不是联系人/潜在客户/帐户实体类型,并且它有效!但是,我需要联系人/潜在客户/帐户实体类型而不是成员列表。如果有人帮助我走出这条黑暗的 MSCRM 隧道,我将不胜感激!

在这里,完整的堆栈跟踪:

[OutOfMemoryException:引发了“System.OutOfMemoryException”类型的异常。] System.ServiceModel.Security.SecurityUtils.ReadContentAsBase64(XmlDictionaryReader reader, Int64 maxBufferSize) +197 System.ServiceModel.Security.EncryptedData.ReadCipherData(XmlDictionaryReader reader, Int64 maxBufferSize) + 17 System.ServiceModel.Security.EncryptedType.ReadFrom(XmlDictionaryReader reader, Int64 maxBufferSize) +858 System.ServiceModel.Security.WSSecurityOneDotZeroReceiveSecurityHeader.DecryptBody(XmlDictionaryReader bodyContentReader, SecurityToken token) +80 System.ServiceModel.Security.WSSecurityOneDotZeroReceiveSecurityHeader.ExecuteMessageProtectionPass(Boolean hasAtLeastOneSupportingTokenExpectedToBeSigned) +1611 System.ServiceModel.Security.ReceiveSecurityHeader.Process(时间跨度超时,ChannelBinding channelBinding, ExtendedProtectionPolicy extendedProtectionPolicy) +1576 System.ServiceModel.Security.MessageSecurityProtocol.ProcessSecurityHeader(ReceiveSecurityHeader securityHeader, Message& message, SecurityToken requiredSigningToken, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates) +205 System.ServiceModel.Security.SymmetricSecurityProtocol.VerifyIncomingMessageCore(Message& message,字符串演员,TimeSpan 超时,SecurityProtocolCorrelationState[] correlationStates)+637 System.ServiceModel.Security.MessageSecurityProtocol.VerifyIncomingMessage(消息和消息,TimeSpan 超时,SecurityProtocolCorrelationState[] correlationStates)+371 System.ServiceModel.Channels.SecurityRequestChannel.ProcessReply(消息回复,SecurityProtocolCorrelationState相关状态,TimeSpan 超时)+471 System.ServiceModel.Channels.SecurityRequestChannel.Request(消息消息,TimeSpan 超时)+175 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan 超时)+22 System.ServiceModel.Channels.ServiceChannel.Call (字符串操作,布尔单向,ProxyOperationRuntime 操作,Object[] 输入,Object[] 输出,TimeSpan 超时)+517 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime 操作)+88 System.ServiceModel.Channels.ServiceChannelProxy .Invoke(IMessage 消息) +453 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 类型) +237 Microsoft.Xrm.Sdk.IOrganizationService.RetrieveMultiple(QueryBase 查询) +0 Microsoft.Xrm.Sdk.Client .OrganizationServiceProxy.RetrieveMultipleCore(QueryBase query) +626 Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveMultiple(QueryBase query) +39 IMPlugin.MarketingListHelper.getMembersAndCountOfChosenMarketingList(OrganizationServiceProxy service, Guid selectedMarketingListGuid, Entity entityType) 在 C:\Users\Zafer\Documents \Visual Studio 2010\Projects\IMPlugin\MarketingListHelper.cs:130 IMPlugin.IM_SMS.fillMainPanel(Double mainPanelHeight) 在 C:\Users\Zafer\Documents\Visual Studio 2010\Projects\IMPlugin\IM_SMS.aspx.cs:96 IMPlugin。 IM_SMS.Page_Load(Object sender, EventArgs e) in C:\Users\Zafer\Documents\Visual Studio 2010\Projects\IMPlugin\IM_SMS.aspx.cs:42 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o , 对象 t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy。回调(对象发送者,EventArgs e)+35 System.Web.UI.Control.OnLoad(EventArgs e)+91 System.Web.UI.Control.LoadRecursive() +74 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint , 布尔型 includeStagesAfterAsyncPoint) +2207

4

1 回答 1

5

存在 5000 限制的原因是作为一个粗略的障碍来防止您遇到的问题。您已经绕过了软件限制,现在需要克服硬件限制(内存不足)...

您没有说明如何编写代码或将结果用于什么目的,但我认为在执行查询后会有额外的处理。在此基础上,我的建议是您在查询表达式中引入分页,分批处理 5000 条记录。

一个粗略的例子:

// get records to process
string pagingCookie = null;
bool moreRecords = false;
int pageNum = 1;
DataCollection<Entity> myBatchOfRecords;    

bool continueProcessing = true;
while (continueProcessing)
{
    myBatchOfRecords = GetRecords(pageNum, ref pagingCookie, ref moreRecords);

    // process those records
    ProcessRecords(myBatchOfRecords);
    pageNum++;    
    continueProcessing = moreRecords;
}

function DataCollection<Entity> GetRecordsList(int pageNumber, ref string pagingCookie, ref bool moreRecords){
    var query = new QueryExpression(blahblahblah...);
    query.PageInfo = new PagingInfo { 
        Count = 5000, 
        PageNumber = pageNumber, 
        PagingCookie = pagingCookie };
    var results =  myOrgService.RetrieveMultiple(query);
    pagingCookie = matchedContacts.PagingCookie;
    moreRecords = matchedContacts.MoreRecords;
    return results;
}
于 2012-07-23T11:50:48.210 回答