I am using Troy Goode paged List in my project.
Usually you just load it with IEnumerable, startindex and the number of elements, and it all works.
Now, however, I'm trying to pass it an IEnumerable, which I generate as follows:
private static IEnumerable<Color> GetColors(Query query)
{
IndexSearcher searcher = new IndexSearcher(luceneIndexpath);
Hits hitColl = searcher.Search(query);
List<int> ids = new List<int>();
int id = 0;
for (int i = 0; i < hitColl.Length(); i++)
{
if (Int32.TryParse(hitColl.Doc(i).GetField("id").StringValue(), out id))
ids.Add(id);
}
foreach (int uniqueId in ids.Distinct<int>())
{
yield return ColorService.GetColor(uniqueId);
}
}
- EDIT -
PagedList works, but asks for revenue for ALL of my Color objects, and not just for paged pages. This course disables all use of the PagedList and can lead to massive enumerations.
- EDIT -
, Count(), ids.Distinct(int) ColorService.GetColor() .