CRMService.Fetch(XML) 5000 row max

Mar 2, 2010 at 9:54 AM

I came across a rather nasty problem with the CRMService.Fetch call.

It only returns 5000 records by default.

I have attempted to find a reference on the site for this, but was unsuccessful and thus assume that it’s not catered for.

I have found some suggestions on ways to fix this problem up and I can implement them, but I was hoping that the next release will include some kind of fix for it so that when I implement the new version, I don’t have to re-implement my fix.

I would appreciate your feedback on this.

Regards,

 

Brian Minnaar

Developer
Mar 2, 2010 at 10:30 AM

This is a feature of CRM itself.The Fetch method is limited to 5000 by default. This can be changed in the registry settings on the server.

Another option is to use Skip() and Take() if you have more than 5000 items to get all items manually.

You can find some more information here: http://ronaldlemmen.blogspot.com/2007/04/fetchxml-into-dataset.html

Coordinator
Mar 2, 2010 at 1:15 PM

Lemmen also has the required registry hack that makes CRM return more records:

http://ronaldlemmen.blogspot.com/2006/08/fetch-all-records.html

Michael

Mar 2, 2010 at 3:58 PM

mmm, is the registry hack supported?

"2) Most of the postings are about unsupported modifications. If you do apply these changes to your implementation, then I, my employer and Microsoft cannot be hold responsible for any issues that it might cause."

Sounds a bit risky...

Changing the c# sounds like a better option, but of little use if it's going to be overridden in the later versions? Maybe we can make it configurable?

Regards,

Brian Minnaar

 

Coordinator
Mar 2, 2010 at 4:14 PM

Microsofts take on the issue is here: http://support.microsoft.com/kb/911510

You can emulate the paging stuff that Microsofts recommends by doing Skip/Take and looping (this is also what melg suggests). There's an example here:

http://linqtocrm.codeplex.com/wikipage?title=Querying%20CRM%20with%20Linq

Feel free to to implement toggleable automatic paging using hasmorerecords or similar. If you submit a patch, We are very likely to merge it.

Michael

Mar 2, 2010 at 6:57 PM

Ok, so I will implement a fix and test it and then once I am done I will submit the changes so you can merge it?

 

Coordinator
Mar 2, 2010 at 7:16 PM

Exactly!

Patches go here: http://linqtocrm.codeplex.com/SourceControl/PatchList.aspx

(We have some unmerged ones in the pipe, I will get my act together soon).

Michael

Mar 2, 2010 at 7:20 PM

No Worries, I love the implementation so fare and this is the first show stopper I have come across.

I love reducing code and with your work I came down from 1100 to 300 lines...

Thank you!!

Regards,

Brian Minnaar

 

Coordinator
Mar 4, 2010 at 12:07 PM

Sounds cool. If you are contemplating a major rewrite, you might want to take a look at http://www.codeplex.com/IQToolkit