First time using AutoMapper and I'm have a hard time figuring out how to use it.
I'm trying to map a ViewModel to my Database Tables.
My ViewModel looks like this...
public class AddressEditViewModel
{
public AddressEdit GetOneAddressByDistrictGuid { get; private set; }
public IEnumerable<ZipCodeFind> GetZipCode...
Hi all,
I am using AutoMapper in my project along with, NHibernate and ASP.NET MVC 2.
As the title states, if I have a list of DTOs or a DTO inside the parent DTO that I am mapping to the View Model, should I flatten out the inner DTOs as well ?
Edit:
Should I write view model classes for the internal objects as well or should I use ...
Calling all AutoMapper gurus!
I'd like to be able to map object A to object B differently depending on context at runtime. In particular, I'd like to ignore certain properties in one mapping case, and have all properties mapped in another case.
What I'm experiencing is that Mapper.CreateMap can be called successfully in the different m...
Does anyone have a technique to automap (using Automapper) references to child entities. So say I have a ViewModel:
class AddressModel
{
int Id;
string Street;
StateModel State;
}
class StateModel
{
int Id;
string Name;
}
And I pass this into a repository to map to equivalent entities in Entity Framework. When Aut...
If I have a one-to-many relationship and I want to transorm this into a list of flat Dto-s where some attributes of parent and some of child appear in a dto, is this something that is supported out-of-box with AutoMapper? For example if I have something like this
Parent
1. ParentId
2. ParentAttr1
3. List<Child>
Child
1. ChildId
2. C...
I have the following code:
[SetUp]
public void SetMeUp()
{
Mapper.CreateMap<SourceObject, DestinationObject>();
}
[Test]
public void Testing()
{
var source = new SourceObject {Id = 123};
var destination1 = Mapper.Map<SourceObject, DestinationObject>(source);
var destination2 = Mapper.Map<ObjectBase, ObjectBase>(sour...
It is my understanding I can configure AutoMapper in the following way and during mapping it should format all source model dates to the rules defined in the IValueFormatter and set the result to the mapped model.
ForSourceType<DateTime>().AddFormatter<StandardDateFormatter>();
ForSourceType<DateTime?>().AddFormatter<StandardDateFormat...
Hi!
I would like to make a deep copy of a complex object tree using AutoMapper.
The problem is that for each member I would like to construct a new object and then map it, and not simply copying the existing one.
Here it is an example:
public abstract class Test
{
public Test()
{
this.Id = Guid.NewGuid(...
Hi everybody... I'm developing a asp.net mvc application with nhibernate and I would not like to expose my objects mappings with NHibernate, so I created DTO for each entity and I'm trying to convert my Domain objects to DTO and send it to View. So I have in my sollution:
ClassLibrary with my Domain (for NHibernate) and DTO objetcs
Cla...
I'm using AutoMapper in a number of projects within my solution.
These projects may be deployed independantly, across multiple servers.
In the documentation for AutoMapper it says:
If you're using the static Mapper
method, configuration only needs to
happen once per AppDomain. That means
the best place to put the
configurati...
I am using automapper (successfully up to a point) to perform a polymorphic map between two interfaces like so:
configure.CreateMap<IFrom, ITo>()
.Include<FromImplementation1, ToImplementation1>()
.Include<FromImplementation2, ToImplementation2>()
... ;
This works fine. In addition however, the interfaces include method si...
I am using Fluent NHibernate's (1.0 RTM) automapping feature to create my oracle database schema. My issue is that all the tables are using a single "hibernate-sequence", whereas I would prefer (and my boss would demand) a sequence generator for each table.
Any ideas?
...
Given the classes:
public class Person
{
public string Name { get; set; }
}
public class Student : Person
{
public int StudentId { get; set; }
}
public class Source
{
public Person Person { get; set; }
}
public class Dest
{
public string PersonName { get; set; }
public int? PersonStudentId { get; set; }
}
I want...
We are getting an Automapper error the FIRST time we run our Unit Tests in VS 2008 (MSTest).
"Missing type map configuration or unsupported mapping. Exception of type 'AutoMapper.AutoMapperMappingException' was thrown"
If we re-run the tests ("Run Checked Tests") then they all pass. Only 2 out of the 4 developers are having this issue. ...
Is possible with Automapper to map a flat object to complex object graph?
Mapper.CreateMap<PersonDto,Person>()
Map PersonDto.BirthCertificateFatherName to Person.BirthCertificate.FatherName
...
I frequently use AutoMapper to map Model (Domain) objects to ViewModel objects, which are then consumed by my Views, in a Model/View/View-Model pattern.
This involves many 'Mapper.CreateMap' statements, which all must be executed, but must only be executed once in the lifecycle of the application.
Technically, then, I should keep them ...
A short while ago I'm sure I read that is was possible to use AutoMapper to map the validation attributes from the domain model to the view model, i can't find that post any more though!
Has anybody seen any code or know if it would be possible to do this? This would give the added benefit of not repeating validation in both ViewModel +...
I have this mapping defined
Mapper.CreateMap<Telephone, TelephoneDTO>()
.ForMember(dto => dto.Extension, opt => opt.MapFrom(src => src.Extension))
.ForMember(dto => dto.Number, opt => opt.MapFrom(src => src.Number))
.ForMember(dto => dto.Type, opt => opt.MapFrom(src => src.TelephoneType.Id));
when i do
IList<TelephoneDTO> dtos = Map...
I have a source object that looks like this:
private class SourceObject {
public Enum1 EnumProp1 { get; set; }
public Enum2 EnumProp2 { get; set; }
}
The enums are decorated with a custom [Description] attribute that provides a string representation, and I have an extension method .GetDescription() that returns it. How do I ma...
After lots of reading about serialization, I've decided to try to create DTOs. After more reading, I decided to use AutoMapper.
What I would like to do is transform the parent (easy enough) and transform the entity properties if they've been initialized, which I've done with ValueResolvers like below (I may try to make it generic once I...