Try our conversational search powered by Generative AI!

How to retrieve ALL contacts?


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 "" file.

So, I tried to do it like this instead:

var filterElements = new FilterElement[1];
filterElements[0] = 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 "")

Does anyone have a solution to retrieve ALL contacts?

Increasing the value in the "" 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... 

Sep 26, 2014 7:34

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.



Sep 26, 2014 10:55

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.

Sep 26, 2014 14:05

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 :)



Sep 26, 2014 14:10

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.

Sep 26, 2014 14:15
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.