I created the following extension method
public static T Map<TEntity,T>(this TEntity entity) where TEntity : IEntity
{
return Mapper.Map<TEntity, T>(entity);
}
This allows you to use
Db.ExchangeSets.FirstOrDefault().Map<ExchangeSet, ExchangeSetSimpleViewModel>()
However, I am wondering if there is a way to change the extension method, so I can name the short version as follows
Db.ExchangeSets.FirstOrDefault().Map<ExchangeSetSimpleViewModel>()
Note:
Whether to use an autoperper like this is outside the scope of the question, the larger the fact-finding mission
<h / "> Update
For those of you who play at home, using scotts comment, I managed to find an additional option for the above function in the Universal extension method for automapper
public static T Map<T>(this IEntity entity)
{
return (T)Mapper.Map(entity, entity.GetType(), typeof(T));
}
However, AutoMapper aside, this is not the answer to the real question and will be honored accordingly