I can understand what the error is saying - it can't compare a list. Not a problem, other than the fact that I don't know how to not have it compare a list when I want to page through a model with a list as a property.
My Model:
Event : IEvent
int Id
string Title
// Other stuff..
LazyList<EventDate> Dates // The "problem" property
Method which pages the data (truncated):
public JsonResult JsonEventList(int skip, int take) {
var query = _eventService.GetEvents();
// Do some filtering, then page data..
query = query.Skip(skip).Take(take);
return Json(query.ToArray());
}
As I said, the above is truncated quite a bit, leaving only the main point of the function: filter, page and return JSON'd data.
The exception occurs when I enumerate (.ToArray()
). The Event
object is really only used to list the common objects of all the event types (Meetings, Birthdays, etc - for example). It still implements IEvent
like the other types, so I can't just remove the LazyList<EventDate> Dates
property unless I no longer implement IEvent
Anyway, is there a way to avoid this? I don't really want to compare a LazyList
when I page, but I do not know how to resolve this issue.
Thank you in advance! :)