Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

The project is similar to AutoMapper, but implements projections with LinqExpression not Reflection

branch: master


Some time ago I moved it in this project, Latest version is now there, the project now is a part of DataAvail.Framework solution. This solution integrate utilities to work with data Services such as CORS, JSON support, web service autorization via standard ASP auth mechanism and other utilities. You can separate LinqMapper project from there if you want. In case of any questions feel free to contact!


The Jimmy Bogard’s library AutoMapper is an excellent tool but unfortunately it doesn’t support projections via Linq - see description of the problem by Jimmy himself here. This library is attempt to naive solution of the problem defined. The top layer of this library is intentionally made similar to one of AutoMapper, but internals are very simplified and now supports only scare of the whole projections available in LINQ. Create projections

Similar to AutoMapper library the mapping by projection is created via

LinqMapper.CreateMap<SrcType, DestType>()

The line above create default mapping between type SrcType and DestType. Default mapping follow these rules:

  1. Properties with the same name and type (simple) are mapped.
  2. Properties with the same name and type (complex, if there is defined mapping for these types) are mapped.
  3. Properties with the same name and both derived from IEnumerable of complex type (where defined mapping between them) are mapped

Now you can add additional mapping rules to the defaults.

Custom mapping rules


Map destination property from source’s property defined in option. LinqMapper.CreateMap<SrcType, DestType>() .MapFrom(p => p.DestName, opt => opt.MapFrom(s => s.SrcName));


Ignore mapping for property. LinqMapper.CreateMap<SrcType, DestType>() .MapFrom(p => p.DestName, opt => opt.Ignore());


Custom mapping between source and destination. LinqMapper.CreateMap<SrcType, DestType>() .MapFrom(p => p.DestName, opt => opt.ResolveUsing( s => s.SrcName + “I see you”));

Custom mapping should be defined in fashion known by underlying LINQ provider.


IQueryable<TSrc> dest = LinqMapper.Map<TSrc, TDest>(IQueryable<TSrc> Src, params string [] Expands)

Map source query to destination by defined rules.

The second parameter define which complex properties should be projected for query. For example if Item source entity has Parent property (also entity) - one should be defined in the list of the Expands in order to be selected from underlying data source (same for the properties with enumerable types).

LinqMapper.Map<TSrc, TDest>(srcQueryable, “Parent”)

Something went wrong with that request. Please try again.