I have the classes:
public class Person{ /* Props here */ }
public class PersonViewModel { /* Props here */ }
Then the list:
If you're using IQueryable
lists here (from EF or NH, for example) you can use the AutoMapper.IQueryableExtensions
methods, Project()
and To()
.
This is my first time with AutoMapper, but I'm succeeding by creating a map for just the model:
Mapper.CreateMap();
Mapper.AssertConfigurationIsValid();
And then using the IQueryableExtension
methods Project()
and To()
:
using AutoMapper.QueryableExtensions;
...
IQueryable people = new List().AsQueryable(); //actually from ORM
IQueryable peopleVM = people.Project().To();