Use this tag for version specific questions about AutoMapper 2 - the convention-based object-to-object mapper and transformer library for .NET. When using this tag also include the more generic [automapper] tag where possible.
I'd like to be able to do something like this using automapper:
Mapper.CreateMap()
.ForMember d.Member, "THIS STRING">();
I'd like d.Member to always be "THIS STRING" and not be mapped from any particular member from…
I have these classes:
public class Person {
public int Id{ get; set ;}
public string FirstName{ get; set ;}
public string LastName{ get; set ;}
}
public class PersonView {
public int Id{ get; set ;}
public string FirstName{ get;…
Suppose I have the following entities (classes)
public class Target
{
public string Value;
}
public class Source
{
public string Value1;
public string Value2;
}
Now I want to configure Auto Map, to Map Value1 to Value if Value1 starts…
Ignoring the ResolveUsing overloads that take an IValueResolver, and looking only at these 2 methods:
void ResolveUsing(Func resolver);
void MapFrom(Expression> sourceMember);
The main difference…
I have the following model:
public class Tag
{
public int Id { get; set; }
public string Name { get; set; }
}
I want to be able to use AutoMapper to map the Name property of the Tag type to a string property in one of my viewmodels.
I have…
I am using auto mapping first time.
I am working on c# application and I want to use auto mapper.
(I just want to know how to use it, so I don't have asp.net app neither MVC app.)
I have three class library projects.
I want to write transfer…
Suppose i have a source class:
public class Source
{
//Several properties that can be mapped to DerivedBase and its subclasses
}
And some destination classes:
public class DestinationBase
{
//Several properties
}
public class…
I updated from AutoMapper 2.0.0 to 2.2.0 today and realized the update broke some code. Wanted to ask about it here before posting as an issue on the automapper github site.
One of my destination types initializes a collection property like…
I am using automapper to map source and destination objects. While I map them I get the below error.
Expression must resolve to top-level member. Parameter name: lambdaExpression
I am not able resolve the issue.
My source and destination objects…
I have two classes below:
public class Module
{
public int Id { get; set; }
public string Name { get; set; }
public string ImageName { get; set; }
public virtual ICollection Pages { get; set; }
}
public class ModuleUI
{
…
Today I upgraded a fully functioning application using AutoMapper v1.1 to now use AutoMapper v2.1 and I am coming across some issues that I never encountered using the previous version.
Here is an example of my code mapping back from Dto to Domain…
I'm using Automapper to map my NHibernate proxy objects (DTO) to my CSLA business objects
I'm using Fluent NHibernate to create the mappings - this is working fine
The problem I have is that the Order has a collection of OrderLines and each of these…
Can I use inheritance mapping in AutoMapper (v2.2) for maps with the same Source type but different Destination types?
I have this basic situation (the real classes have many more properties):
public abstract class BaseViewModel
{
public int…
What is the best way to map inner objects with Automapper 2.0
Use the solution in this question (Automapper 1.0)
Create a Custom Value Resolvers
?
public class DTOObject
{
// MainObject
public int Id { get; set; }
public string Name {…
I'm trying to use AutoMapper to flatten multiple levels of arrays.
Consider the following source classes:
class X {
public string A { get; set; }
public Y[] B { get; set; }
}
class Y {
public string C { get; set; }
public Z[] D {…