Click here to Skip to main content
15,894,825 members
Everything / AutoMapper

AutoMapper

AutoMapper

Great Reads

by DiponRoy
Conversion of complex object to a list of objects
by George Swan
This piece illustrates how to construct a simple generic mapper that will copy every property value from one class to another where the name and type of the property is the same in both classes; it goes on to suggest a way of constructing generic tests that can be used for any instance of the
by Alessandro Magistroni
How to validate Automapper configuration using AssertConfigurationIsValid
by OwenDavies
A fix for people experiencing the same issue with AutoMapper 3.2.1

Latest Articles

by Alessandro Magistroni
How to validate Automapper configuration using AssertConfigurationIsValid
by DiponRoy
Conversion of complex object to a list of objects
by Adam Flow
A short look into the possibilities of AutoMapper's operation options
by OwenDavies
A fix for people experiencing the same issue with AutoMapper 3.2.1

All Articles

Sort by Score

AutoMapper 

26 Jul 2022 by DiponRoy
Conversion of complex object to a list of objects
18 Jan 2016 by Sascha Lefèvre
I don't know if it can be done with AutoMapper. But this is how you could do it yourself, not including the Repository-call. There's a generic and non-generic version of the mapping-method; I think you should be able to use the generic one.using System;using...
7 Feb 2017 by Richard Deeming
Assuming you want a direct mapping from one type to the other, something like this should work:static void CreateDynamicTestClassMap(IMapperConfigurationExpression configuration){ var dynamicObject = new { Name = default(string), Age = default(int) }; var map =...
2 Oct 2019 by George Swan
This piece illustrates how to construct a simple generic mapper that will copy every property value from one class to another where the name and type of the property is the same in both classes; it goes on to suggest a way of constructing generic tests that can be used for any instance of the
12 Jul 2021 by Richard Deeming
The problem is you are loading the entity with the specified ID, then creating a new instance of the class with the same ID, and attaching that new instance to the context. Instead, you should be updating the existing entity instance: Patient...
13 Mar 2023 by Alessandro Magistroni
How to validate Automapper configuration using AssertConfigurationIsValid
21 Oct 2013 by Super Lloyd
I got some pattern Nazi at work and they are like "you MUST use AutoMapper otherwise we refuse your project"!When I look at AutoMapper I am like meh...I can vaguely see that some people might find it useful in some cases....But, almost on matter of principle myself, I hate pattern Nazi...
21 Oct 2013 by Ranjan.D
Automapper is an amazing small, simple and elegant mapper in this world and moreover it's OpenSource :)
28 Oct 2013 by Gopal Rakhal
Hello all, I am very beginner for MVC and started with MVC using Automapper and m stuck in getting data from multiple tables using automapper, is it possible to do so or there is else way to solve same please suggest me...
28 Oct 2013 by shek124
Hi,I hope below link will help youLinq to SQL[^]
4 Dec 2013 by ahmed ali mohd
Edit is not saving then changes in MVC4 AutomapperBelow is my code..public ActionResult Edit(int id, User userDetails)// { try { var dbContext = new MyDBDataContext(); Mapper.CreateMap(); ...
1 Mar 2014 by OrianaItSolutions
Hi,Your CreateMap is missing destination class. Also please check the names of properties are in sync in both the classes.
15 Jul 2015 by AbhishekDotNet
Hi,I am novice to AutoMapper and trying to implement it.my code :Mapper.CreateMap() .ForMember(d => d.RoleId, o => o.MapFrom(s => s.RoleId)) .ForMember(d => d.Role, o => o.MapFrom(s => s.Roles.Role)).ReverseMap().ForMember(s =>...
17 Jan 2016 by vacho2
I would like to propagate entity framework include properties across architecture.1. Starting at the service layer where these include properties come as an argumentIEnumerable GetUsers(user => user.Classes);2. The method getUsers must translate this expressions from ViewModel to...
14 Feb 2016 by Chitranjan bariya
public class ModuleDTO { public int ModuleID { get; set; } public int ProjectID { get; set; } public string ModuleName { get; set; } public string ModuleVer { get; set; } public bool Active { get; set; } public virtual ProjectDTO...
13 Sep 2016 by khosro goudarzi
I am developing a App with pjsip4net (it is an open source project SoftPhone) .I add AutoMaper.Net4 DLL to references in the project .but when I run this code to get project's assemblies AutoMapper.Net4 it is not in list . why ?AppDomain currentDomain =...
9 Dec 2016 by Дима_89
I'm using Automapper and three-layered architecture in my application. I have a method which takes Linq query (LambdaExpression) as a parameter. To pass this parameter in another layer I need to remap it. So, I created an ExpressionExtension class, which is responsible for returning remapped...
7 Feb 2017 by KuntalBose
I have bellow function which returns a list of dynamic object public List getlist() { List d = new List(); d.Add(new { Name = "A", Age = 12 }); d.Add(new { Name = "B", Age = 10 }); ...
18 Sep 2017 by fatihkaratay
I have a dotnetcore 2.0 angular project. Inside the project, I have Project, Owner, and Status domain classes. The relationships are like below: 1 Owner can have multiple Projects, 1 Project should have only one status. I use AutoMapper to map those classes in order to create API resources. My...
24 Jan 2018 by Onur ERYILMAZ
Hi, I have some issues with automapper. I have two objects and I want to convert these. First object; public partial class WorkCommandDocuments { public int ID { get; set; } [Required] [StringLength(300)] public string WorkCommandNumber { get; set; } ...
24 Jan 2018 by Onur ERYILMAZ
EDIT: I solve this problem with adding default constractor to WorkCommandDoc object.
31 Jul 2018 by Member 13466003
I have a source object and destination object with a enum property. One of the member of this enum property is different for each object. But I need to map it using Automapper. How I can achieve it?. example code snippet: Source Class: public class SourceClass { public SourceClassification...
31 Jul 2018 by Nathan Minier
Just configure a map for the enums: Mapper.CreateMap().ConvertUsing(val => { switch(val) { case SourceClassification.Required: return DestinationClassification.Mandate; case SourceClassification.Optional: ...
31 Jul 2018 by George Swan
You just need to tell AutoMapper to map SourceClass.SourceLevel to DestinationClass.Input. It will map on the value of the enum member so Mandate will map to Required. var config = new MapperConfiguration(cfg => { cfg.CreateMap
12 Feb 2020 by OwenDavies
A fix for people experiencing the same issue with AutoMapper 3.2.1
1 Jun 2020 by sam_roy
I have 4 classes namely ClassA, ClassADto, ClassAA(inner class to ClassA) and the final Result class. public class InnerA { public int HouseNumber{get;set;} public string StreetName{get;set;} public string State{get;set;} } public class A {...
1 Jun 2020 by Maciej Los
This is not an answer, but i have too many doubts to post it as a comment. 1. I don't understand the reason of creating two classes containing almost the same data, where an ADto should be a base class for A. Take a deeper look at them: ...
12 Jul 2021 by Member 12955507
I am developing an application in MVC5 that has its own data access layer. In data access layer I have tried mapping object for Add/Update operation. I am using the AutoMapper v4.0.30319 Please find below image for see my code. code image ...
25 Jul 2023 by Member 13304618
I have a design question; thus, no code samples I am trying to create a Web API Core project that would use an EF Core to communicate with a database. I read about the Data Access design pattern and realize that I have to place a Web API project...
25 Jul 2023 by Richard Deeming
Quote: the EF core cannot reference the Web API You've just answered your own question: the mapping needs to be done in a project which has references to both the entity classes and the DTOs you're mapping to. Personally, I'd be inclined to...
30 May 2014 by User 10132546
Using ClassAssert to check property mappings between different object types
26 Nov 2014 by Akhil Mittal
How to do custom mapping and entity to entity mapping with the help of AutoMapper.
3 Sep 2014 by User 6744868
5 useful tips to help get the most from AutoMapper
18 Jun 2016 by saurabhsharmacs
20 Dec 2021 by Adam Flow
A short look into the possibilities of AutoMapper's operation options
13 Sep 2016 by ZurdoDev
If you refer to the documentation, AppDomain.GetAssemblies Method (System)[^], it reads, "Gets the assemblies that have been loaded into the execution context of this application domain."Adding a reference does not actually load the assembly. You would have to be using it in code somewhere...
21 Sep 2017 by Richard Deeming
You don't need to map the member; you just need to map both types. Given: namespace Db { public class Order { public List Ship { get; set; } } public class ShipOnly { public string Name { get; set; } } } namespace Dto { public...
13 Nov 2018 by Vlad Neculai Vizitiu
How to secure Ids on web applications
6 Jun 2018 by Denis Pashkov
Dynamicly configure IMapper object using custom attributes annotations.
10 Apr 2018 by xszaboj
How to setup net core with automapper
30 Apr 2015 by imad afzal
what i m looking for a solution of Multiple values using MVC.The user at front end have various offices in punjab, sindh, balochistan, KPKThe organization have 1 Main Head Offices in each of the above Provinces i.e. punjab, sindh, balochistan, KPK and than the same organization have...
23 Oct 2015 by Kacha Nilkanth
Want to know how I can do mapping while things about mapping two different class with different datatypes fields for inserting and retrieving data from database.class 1 UserModel= public string ProfileImage {get; set;}(viewmodel)class 2 User= public byte[] ProfileImage {get;...
21 Sep 2017 by Member 13229879
I want to map list of Dto to other object to using Automapper Source: public class Order { public List Ship { get; set; } } public class ShipOnly { public string Name { get; set; } } Destination public class Order { public...