Using Automapper to return IQueryable
In order for Automapper to actually perform the mapping, it has to see each element in the IQueryable. Once you've iterated over a queryable, it is no longer queryable as it has been queried already.
For anyone that might miss the comment link, you can use Automapper's [QueryableExtensions][1]
, specifically ProjectTo
. For example:
var collection = _db.Patients
.ProjectTo<PatientDto>(_mapper.ConfigurationProvider);
This will create an IQueryable projection from the db entity.