The newer Project().To()
API takes a totally different route than the "classic" Mapper.Map()
API. I think that the latter would run in your case, but of course you won't have the benefit of the projection trickling thought to the SQL.
During Project().To()
AutoMapper tries to get MemberInfo
s (reflection) from the involved types, which it uses to create lambda expressions. This means that the source properties in a mapping must be members of the source type. Evidently, W.Sessions.AsQueryable().Select(...
is not a member of Workstation
. So somewhere along the line AutoMapper bumps into a null
memberinfo.
So, Project().To()
is a bit restricted. In this particular case a remedy may be to map a Session
with its parents WorkStation
and StaffMember
to the model. Reference navigation properties will map OK with Project().To()
.