We're using Microsoft.CrmSdk.CoreAssemblies 7.0.0.1 with earlier bind, when retriving record from entity collection, sometimes we're getting:
xxx.xxx.Crm.Api.PartyController+<>c__DisplayClass3_0.<DetailsAsync>b__0()]
Unhandled exception System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.MergeEntity(Entity entity)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.<CastIterator>d__97`1.MoveNext()
at Microsoft.Xrm.Sdk.Linq.PagedItemCollection`1.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at xxx.Crm.BusinessLogic.PartyContext.Get(Identifier identifier) in D:\a\1\s\Application\Vxxx.xxx.Crm.BusinessLogic\PartyContext.cs:line 67
at xxx.Crm.Api.PartyController.<>c__DisplayClass3_0.<DetailsAsync>b__0() in D:\a\1\s\Application\xxx.Crm\Api\PartyController.cs:line 76
The query is quite simple, like: _CrmContext.Parties.FirstOrDefault(p => p.xx_name == "KDIE3242"), where _CrmContext is an instance of early bind Crm class we generated using a MS tool from our
Dynamic 365 CRM, it contains all the entities in our CRM. We're using it in a Web API service, getting this error randomly. Any idea why?
Any suggestion is appreciated.
Regards,
Echo