1

Closed

AutoMapper custom expressions errors

description

The following AutoMapper map expression;

Mapper.CreateMap<Employee, EmployeeModel>()
.ForMember(trg => trg.EmployeeName, opt => opt.MapFrom(src => src.FirstName + " " + src.LastName));
Will result in this error: This expression is not supported: ((src.FirstName + " ") + src.LastName)
Closed Nov 9, 2012 at 1:03 PM by Luis_Fernando

comments

Luis_Fernando wrote Oct 21, 2012 at 2:30 AM

Even if it is marked as fixed, it is still necessary to create the mapping in GMM for this to work properly.

For the above example, use the mapping below;

GridModelMapper.CreateMap<Employee, EmployeeModel>()
.MapProperty(employee => employee.FirstName + " " + employee.LastName, model => model.EmployeeName);