When returning a collection of items in a Sitefinity CMS web service, you should always wrap that collection inside of a CollectionContex<T> object, which provides service client with some additional information about the collection.
CollectionContext is a generic type, so when declaring it we need to specify the generic argument which is the type of the items this collection holds.
For example, if we are returning a collection of ResourceEntry objects, we would declare CollectionContext object as follows: CollectionContext<ResourceEntry> on the other hand, if our collection is made of Product object, we would declare CollectionContext object like this:
CollectionContext<Product>
private CollectionContext<ResourceEntry> GetResourcesInternal(string cultureName, string classId, string provider, string sort, int skip, int take, string filter)
{
var manager = Res.GetManager(provider);
CultureInfo cultureInfo = GetCultureInfo(cultureName);
var query = from resoruce in manager.GetResources(cultureInfo)
where resoruce.ClassId == classId
select resoruce;
// extender takes care of it.
if (!string.IsNullOrEmpty(sort))
query = query.OrderBy(sort);
// this is where the quer the query is executed.
int totalCount = query.Count();
// wont fire the process again, when marked as IEnumerable.
var items = query.AsEnumerable().Skip(skip).Take(take);
var collectionContext = new CollectionContext<ResourceEntry>(items)
{
TotalCount = totalCount
};
return collectionContext;
}