I think AutoMapper does the job better here. I modified the map method using AutoMapper as below and it worked
public List<CompositeDTO> MapToDto(IEnumerable<object> data)
{
dtoList = data.Select(Mapper.DynamicMap<CompositeDTO>).ToList();
//foreach (var rec in data)
//{
// dto.InjectFrom(rec );
// dtoList.Add(dto);
//}
return dtoList;
}
All I needed to do was add the alias I used in the linQ query to the CompositeDTO
's property like so P_PersonID
and B_AccountType
I think ValueInjecter should work on adding this feature. I really like not having to create a map before I use it like how it is done in AutoMapper currently for non-dynamic types. I am now using two different object mappers in my code. Is that bad?