Is there any way to validate mappings at compile time? For example, I have an entity with many child entities. If I forgot to add a CreateMap for one of the childen when I try to map ParentX to ParentY the mapping will fail.
I can't think of a way to validate this during compile but I'd love to find a way.
...
I'd like to map a paged list of business objects to a paged list of view model objects using something like this:
var listViewModel = _mappingEngine.Map<IPagedList<RequestForQuote>, IPagedList<RequestForQuoteViewModel>>(requestForQuotes);
The paged list implementation is similar to Rob Conery's implementation here:
http://blog.wekeroa...
Is anyone working on a .NET Compact Framework port of AutoMapper or are there any similar mapping libraries for the .NET Compact Framework?
...
In my ASP.NET MVC 2 (RC) project - I'm using AutoMapper to map between a Linq to Sql class (Media) and a view model (MediaVM). The view model has a SelectList property for a drop down in the view. I have a custom value resolver to populate the SelectList property items from the db, but am wondering if there's a way to pass a couple value...
By picking MVC for developing our new site, I find myself in the midst of "best practices" being developed around me in apparent real time. Two weeks ago, NerdDinner was my guide but with the development of MVC 2, even it seems outdated. It's an thrilling experience and I feel privileged to be in close contact with intelligent programmer...
What’s Automapper for? How will it help me with my domain and controller layer (asp.net mvc)
...
I have 4 classes "CategoryDb","ProductDb", "CategoryDomain", "ProductDomain", "CategoryDb","ProductDb" are from the db side, and "CategoryDomain", "ProductDomain" are from the domain side, i want to use automapper to do mapping from db side to domain side.
public class CategoryDb {
public List<ProductDb> Products { get; set...
Hello,
I was wondering if it is possible to map multiple DTO objects to a single ViewModel object using Automapper?
Essentially, I have multiple DTO objects and would like to display information from each on a single screen in ASP.NET MVC 2.0. To do so I would like to flatten the DTO objects (or parts of them...) into the Viewmodel and ...
I have created presentation model and I want to map it (with AutoMapper) into the ViewModel.
ViewModel is composite / because I'm using partials and I want to reuse for example KeyboardsViewModel also on other views/partials.
How can I map (setup mapping) this presentation model into the ViewModel? Is this the right approach?
Thanks!
...
Not sure if the title makes sense, but here's what I'm doing. I'm using AutoMapper to map my Entity Framework Entities to my DTO objects and vice versa. The issue comes when I try to map the DTO data to the EF entity. There's not a property to property mapping for the EntityKey. To fix this, I do some like the following:
Mapper....
Here are my classes:
public abstract class TypeBase
{
public virtual int? Id { get; set; }
public virtual string Name { get; set; }
}
// various other classes extend TypeBase the same way
public class Color : TypeBase
{
}
public class Template
{
public virtual int? Id { get; set; }
public virtual IList<Style...
I just started using the Entity Framework 1.0 recently and believe I am beginning to feel the pains everyone is talking about. I'm trying to use best practices so I have a set of DTO that get mapped to and from my Entities via AutoMapper.
The real catch is when I'm trying to update an object. The first gotcha was that I could not find ...
It looks like an IValueFormatter takes a value of type object and returns a value of type string, while a ValueResolver<TSource, TDestination> takes a value of any type and returns a value of any type. So, it's more flexible. There is also the matter that, with a ValueResolver, you never need to cast the source to a particular type--you ...
I am using AutoMapper in my ASP.NET MVC website to map my database objects to ViewModel objects and I am trying to use several profiles to map the same types, but using another logic. I had the idea of doing so by reading Matt's blog post where he says:
The really key part is the AutoMapper configuration profile. You can group con...
We are using AutoMapper from Codeplex and for me the destination object has all the properties ending with 'Field', ie cityField and the source object has just city.
I can use the below code to achieve but all of the properties are just suffixed with 'Field' and there are 20 properties.
.ForMember(dest => dest.cityField, opt => opt.Map...
Mapper.CreateMap<A, B>()
.ForMember(dest => dest.defs, opt => opt.MapFrom(origin => origin.abc));
where defs is array of Def (Def[])
how to map?
...
As the title says...
I found this solution http://stackoverflow.com/questions/1526813/automapper-setting-destination-string-to-null-actually-makes-it-string-empty
but It uses the Initialize method so all the mappings behavior would change along the app : O
And I just need do it for a specific mapping.
Thanks in advance.
...
Problem:
I have an AutoMapper converter that takes a Nullable<bool>/bool? and returns a string. I apply this globally to my profile, and it works for true and false but not for null.
Here is what I have in my AutoMapper profile:
CreateMap<bool?, string>()
.ConvertUsing<NullableBoolToLabel>();
And here is the converter class:
pu...
Is it possible to use automapper with Immutabile types.
For example my Domain type is immutable and I want to map my view type to this.
I believe it is not but just want this confirmed.
Also as it is best pratice to have your domain types immutabile, what is the best pratice when mapping your view types to domain types?
...
We're using constructor-based dependency injection, AutoMapper and Unity on a codebase.
We have wrapped AutoMapper with a generic interface...
public interface IMapper<TSource, TDestination>
{
TDestination Map(TSource source);
}
And a class that implements this interface...
public class AutomaticMapper<TSource, TDestination> : I...