1

Why does this work:

var ret = Session.Query<ListingEvent>()
                       .TransformWith<ListingEventProfileTransformer, ListingEventDto>()
                       .ToList();

var ret2 = ret.Where(x => x.EventInstance.Slug == slug);

return ret2;

but this does not:

var ret = Session.Query<ListingEvent>()
                       .TransformWith<ListingEventProfileTransformer, ListingEventDto>()
                       .Where(x => x.EventInstance.Slug == slug);

return ret;

Obviously the 1st one is no good as it needs to enumerate the collection before adding my predicate.

Surely they should both work?!

1 Answers1

0

The second query is still at an IQueryable, so nothing is executed until you force the results to come back. Try this:

var ret = Session.Query<ListingEvent>()
                       .TransformWith<ListingEventProfileTransformer, ListingEventDto>()
                       .Where(x => x.EventInstance.Slug == slug)
                       .ToList(); // Force the results to come back

return ret;
Dominic Zukiewicz
  • 8,258
  • 8
  • 43
  • 61