Extensions for AutoMapper and EF6
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/AutoMapper.EF6 Marking 1.1.1 Oct 31, 2017
.gitignore EF6 extensions Jul 7, 2015
AutoMapper.EF6.sln Marking 1.1 Oct 31, 2017
LICENSE Initial commit Jul 6, 2015
NuGet.config EF6 extensions Jul 7, 2015
README.md Update README.md Jul 7, 2015

README.md

AutoMapper.EF6

Extensions for AutoMapper and EF6

This contains some useful extensions I've used with AutoMapper and EF6. Instead of this:

Mapper.CreateMap<Employee, EmployeeDto>()
  .ForMember(d => d.FullName, opt => opt.MapFrom(src => src.FirstName + " " + src.LastName));

var employees = await db.Employees.ProjectTo<EmployeeDto>().ToListAsync();

You can do this instead:

public class Employee {
  [Computed]
  public string FullName { get { return FirstName + " " + LastName; } }
}
Mapper.CreateMap<Employee, EmployeeDto>();

var employees = await db.Employees.ProjectToListAsync<EmployeeDto>();

This package wraps up calling ProjectTo, the DelegateDecompiler Decompile/DecompileAsync methods, and then the LINQ methods to execute the queryable (ToList, ToArray, Single, SingleOrDefault etc).