Some time ago I moved it in this project, https://github.com/baio/DataAvail.Framework. 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
The line above create default mapping between type SrcType and DestType. Default mapping follow these rules:
- Properties with the same name and type (simple) are mapped.
- Properties with the same name and type (complex, if there is defined mapping for these types) are mapped.
- 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.
Map destination property from source’s property defined in option.
.MapFrom(p => p.DestName, opt => opt.MapFrom(s => s.SrcName));
Ignore mapping for property.
.MapFrom(p => p.DestName, opt => opt.Ignore());
Custom mapping between source and destination.
.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”)