AutoMapper vs ValueInjecter [closed]

as the creator of ValueInjecter, I can tell you that I did it because I wanted something simple and very flexible I really don’t like writing much or writing lots of monkey code like: Prop1.Ignore, Prop2.Ignore etc. CreateMap<Foo,Bar>(); CreateMap<Tomato, Potato>(); etc. ValueInjecter is something like mozilla with it’s plugins, you create ValueInjections and use them … Read more

Where to place AutoMapper.CreateMaps?

Doesn’t matter, as long as it’s a static class. It’s all about convention. Our convention is that each “layer” (web, services, data) has a single file called AutoMapperXConfiguration.cs, with a single method called Configure(), where X is the layer. The Configure() method then calls private methods for each area. Here’s an example of our web … Read more

AutoMapper convert from multiple sources

You cannot directly map many sources to single destination – you should apply maps one by one, as described in Andrew Whitaker answer. So, you have to define all mappings: Mapper.CreateMap<People, PeoplePhoneDto>(); Mapper.CreateMap<Phone, PeoplePhoneDto>() .ForMember(d => d.PhoneNumber, a => a.MapFrom(s => s.Number)); Then create destination object by any of these mappings, and apply other mappings … Read more

How to set up Automapper in ASP.NET Core

I figured it out! Here’s the details: Add the main AutoMapper Package to your solution via NuGet. Add the AutoMapper Dependency Injection Package to your solution via NuGet. Create a new class for a mapping profile. (I made a class in the main solution directory called MappingProfile.cs and add the following code.) I’ll use a … Read more

Does AutoMapper support Linq?

While @Aaronaught’s answer was correct at the time of writing, as often the world has changed and AutoMapper with it. In the mean time, QueryableExtensions were added to the code base which added support for projections that get translated into expressions and, finally, SQL. The core extension method is ProjectTo1. This is what your code … Read more

AutoMapper: “Ignore the rest”?

From what I understood the question was that there are fields on the destination which doesn’t have a mapped field in the source, which is why you are looking for ways to Ignore those non mapped destination fields. Instead of implementing and using these extension method you could simply use Mapper.CreateMap<sourceModel, destinationModel>(MemberList.Source); Now the automapper … Read more