Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

c# - Dynamics CRM OrganizationServiceContext - Suddenly Limiting Records Returned?

Bit of background to this... in my company we have loads of C# jobs that execute at various points throughout the day (mainly overnight) to insert/update records in our Dynamics 365 online environment. We have been in the cloud for over 12 months and these jobs have all been working absolutely fine until a few days ago.

All of a sudden, the jobs that read existing records back from CRM using the CRM SDK DLLS via the ServiceContext.CreateQuery method, have now started to throw OUtOfMemory exceptions once the default timeout has been reached (we default it to 10 minutes). For example, we have about 150,000 contact records which would ordinarily be read back (just the contactid and one other custom field) in under 30 seconds that are now bombing out in multiple C# jobs. The code works if I limit the where clause to include a specific contactid GUID or read back records from an entity that has a small number of records in it.

It is like as if there is now a cap on the no. of records you can read back or something like that. I have seen this problem before if trying to read millions of records back in one go, but not in the region of 100-150k records. This has always worked just fine until now. Anyone else experienced something similar and/or know how to resolve this? I know I can refactor the code to use the service object in conjunction with QueryExpression instead (and read back 5000 records per page at a time) but want to see if there is a way around that as we have a huge amount of code that would need to be reworked.

Thanks

Sample code below...

var records =
            (
                from a in CrmConnection._serviceContext.CreateQuery("contact")
                where a["statecode"] != null
                && a["code"] != null
                && ((OptionSetValue)a["statecode"]).Value == 0
                select new
                {
                    ContactId = (Guid)a["contactid"],
                    Code = (string)a["code"]
                }
            ).ToList();
question from:https://stackoverflow.com/questions/65940385/dynamics-crm-organizationservicecontext-suddenly-limiting-records-returned

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...