LINQ查询获取timedOut

时间:2018-03-07 11:28:22

标签: performance linq wcf dynamics-crm query-performance

我的自定义日志文件中出现以下错误消息:

2018-03-07 15:40:51,897 ERROR - The request channel timed out while waiting for a reply after 00:01:59.9880000. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
mscorlib

服务器堆栈跟踪:

at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

在[0]处重新抛出异常:

 at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest request)
   at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request)
   at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Execute(OrganizationRequest request)
   at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.Execute(OrganizationRequest request)
   at Microsoft.Xrm.Sdk.Linq.QueryProvider.RetrieveEntityCollection(OrganizationRequest request, NavigationSource source)
   at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute(QueryExpression qe, Boolean throwIfSequenceIsEmpty, Boolean throwIfSequenceNotSingle, Projection projection, NavigationSource source, List`1 linkLookups, String& pagingCookie, Boolean& moreRecords)
   at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](QueryExpression qe, Boolean throwIfSequenceIsEmpty, Boolean throwIfSequenceNotSingle, Projection projection, NavigationSource source, List`1 linkLookups)
   at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](Expression expression)
   at Microsoft.Xrm.Sdk.Linq.QueryProvider.GetEnumerator[TElement](Expression expression)
   at Microsoft.Xrm.Sdk.Linq.Query`1.GetEnumerator()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at ACE.Crm.Business.Logic.CustomerCommunicationsLogic.RetrieveCustomers() in C:\Dev\Crm\Active\Src\ACE.Crm.Business\Logic\CustomerCommunicationsLogic.cs:line 541

由于LINQ中的一个过滤条件,这一切都在发生:

var list = (
            from c in _crmRepository.Query<Contact>()
            join cn in _crmRepository.Query<Connection>() on c.ContactId equals cn.Record1Id.Id                
            join a in _crmRepository.Query<Account>() on cn.RecordId2.Id equals a.AccountId.Value
               where c.StateCode.Value == (int)ContactState.Active
               && cn.StateCode.Value == (int)ConnectionState.Active
               && c.BirthDate != null
               && a.ace_NetworkClient.GetValueOrDefault()
            select new ReturnedCustomerDataClass
            {
                AccountId = a.AccountId.GetValueOrDefault(),
                ContactId = c.ContactId.GetValueOrDefault(),
                aceContactId = c.ace_ContactID,
                <<<<<<< Many Other Fields>>>>>>>>>>>
            }

Where条款中,您可以看到过滤器a.ace_NetworkClient.GetValueOrDefault()。 当我删除此过滤器时,我的查询没有响应并被卡住。如果我删除过滤器&& a.ace_NetworkClient.GetValueOrDefault() {ace_NetworkClient是一个布尔字段},任何人都可以告诉我出了什么问题。

在我的结果中,我想要ace_NetworkClient标志为真或假的客户,这就是为什么我删除了现有条件,为本地组织获得正确结果的原因。但由于数据量大而无法生产组织。

由于

0 个答案:

没有答案