I assumed that CustomerContext.Current.GetAllContacts() would give me all contacts in my Commerce site, but it does not... It returns the number of contacts based on which value you have in your "baf.data.metaobject.config" file.
So, I tried to do it like this instead:
var filterElements = new FilterElement;
filterElements = new FilterElement("propertyName", FilterElementType.In, "values-that-include-all-users");
var memberList = BusinessManager.List("Contact", filterElements);
But, the BusinessManager.List(...) has the same behaviour, it only returns the first X contacts. (X is defined in "baf.data.metaobject.config")
Does anyone have a solution to retrieve ALL contacts?
Increasing the value in the "baf.data.metaobject.config" file is not an option. We have 1 million contacts, and that makes it impossible to browse the site. It consumes all memory on the server and crashes due to a timeout...
I believe you can call this from BusinessManager
public static EntityObject List(string metaClassName, FilterElement filters, SortingElement sorting, int? start, int? count)
specify start and count then you'll be able to get all your contacts without making a timeout or out of memory exception.
Thank you :) That seems to work, but I did a iisreset after waiting 15 minutes with agressive cpu and memory consumption.
It will be hopeless to implement this in a working environment, so I'm changing strategy. I will do SQL queries instead.
I mean you'll be able to get by paging. Getting all 1 million contacts at once is putting too much pressure on the system.
I guess you'll need only some fields of the contact - it should be fine to get 500 contacts each call, create the simplified objects then them to the list.
If you're doing that already then I'm sorry, SQL Queries should be your best bet :)
Yes, but I think my queries will be easier (faster) to run as a sql query instad of using filters in EPiServer. I am doing an export where I can most of the information in the cls_contact table.