automapper

AutoMapper With Generic Type Inheritance

Hi, I'm trying to map CustomerDTO with my domain entity ICustomer with AutoMapper. Everything works fine for first inheritance level but not for the others. I'm using Interfaces for my domain model since concrete types are injected by StructureMap from my LinqToSql Database Infrastructure layer. public interface IBaseEntity<TPk> { ...

AutoMapper with IList<Item>

I have Article class with property private IList<Tag> _tags; public virtual IList<Tag> Tags { get{ if(_tags == null) _tags = TagService.GetTags(this); return _tags; } } Since there is no SET for Tags automapper will not set tags when mapping from viewmodel to view. Any ideas? ...

How to map EditModel to Command Messages?

Jimmy Bogard at Los Techies says that he maps his EditModel to Command Messages instead of mapping EditModel to DomainModel. Can anyone explain this further? ...

Getting an exception with AutoMapper

I'm unit testing a method which uses automapper to map a class from my domain to a linq to sql class. Roughly, the classes and mapping are below (The SupplierEligibilityAllocated is a L2S auto generated class). public class SupplierEligibilityTransactionByQuantity { public decimal Eligibility { get; private set; } public decima...

Automapper: reusing created maps

If for example I have something like this: Mapper.CreateMap<Foo,FooDto>() .ForMemeber( ...; and I have class Bar { public Foo Foo { get; set; } } class BarDto { public FooDto Foo { get; set; } } than I have to repeat the mapping logic for Foo to FooDto again: Mapper.CreateMap<Bar,BarDto>() .ForMemeber(... At the...

AutoMapper: Mapping between a IDataReader and DTO object.

I have a DataReader which contains the result of a stored procedure. The naming convention for the columns use underscores for spaces. I have been able to successfully map between IDataReader and IEnumerable, but only if the fields match exactly. I do not want to the naming convention used in the stored procedures to dictate the way I ...

ASP.NET MVC ViewModel mapping with custom formatting

The project I'm working on has a large number of currency properties in the domain model and I'm needing for format these as $#,###.## for transmitting to and from the view. I've had a view thoughts as to different approaches which could be used. One approach could be to format the values explicitly inside the view, as in "Pattern 1" f...

Is it possible to use a Fluent NHibernate convention to map all ICollections as sets?

Is it possible to use a Fluent NHibernate convention to map all ICollections as sets? I have an entity like so: public class NoahsArk { public virtual ICollection<Animal> Animals { get; set; } public NoahsArk() { Animals = new HashSet<Animal>(); } } With fluent mappings, this property would be mapped as HasMan...

Custom Id column in the Fluent NH entity name

I am using S#arp architecture with Fluent Nhibernate and Automapper on a legacy DB. The id column of one of the tables is different from the Automapping convention and therefore I tried to override it without success. I end up with this error FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete config...

It is possible to use WCF + DTO's + Automapper?

I want to use automapper with a structure that uses WCF + DTO's but I want to know how the question of the eager loading with entity framework 4.0 work with the mappings of the automap. ...

No persister for entity using AutoMap in Fluent Nhibernate?

I'm trying to utilise FluentNHibernate with Automapping but am receiving the following error No persister for: nHibernateSpike.Entities.Route NHibernate.MappingException: No persister for: nHibernateSpike.Entities.Route Here's the relevant stuff; var model = AutoMap.AssemblyOf<Route>(). Where(t => t.Namespac...

How to handle view model with multiple aggregate roots?

At the moment, i got quite badly fashioned view model. Classes looks like this=> public class AccountActionsForm { public Reader Reader { get; set; } //something... } Problem is that Reader type comes from domain model (violation of SRP). Basically, i'm looking for design tips (i.e. is it a good idea to spli...

AutoMapper custom type converter dependencies

I am trying to implement Automapper to map a ViewModel to an Entity where one of the properties of the Entity is also an Entity. I want my converter to use NHibernate's ISession.Load<> method to load this. So the question is what is the best way of injecting ISession into my ITypeConverter implementation? Also one thing to keep in mind...

Automapper newbie question regarding list property

As a new fan of AutoMapper, how would I use it to do the following: Given the following classes, I want to create FlattenedGroup from Group where the list of item string maps to the title property of Item. public class Group { public string Category { get; set; } public IEnumerable<Item> Items { get; set; } } public class Item...

Fluent NHibernate (with automapping) not saving join table values in many-to-many

I am not exactly an NHibernate expert, so this may be a lack of understanding in that department. I have two simple entities with a many-to-many relationship public class Category { public virtual int Id { get; private set; } public virtual string Name { get; set; } public virtual string Description { get; set; } public ...

Entity Framework (Entities Classes) Serialization

Hi , After reading about Enitity Framework , i have some questions: 1] What is the best way to transfer Entities between tiers ? a] do i must create lighter DTOs for this or i can Effectively serialize the Entitiy and transfer it ? b] if i must create light DTOs,for Efficency, and after i saw the nice usage of Automapper ...

Can Fluent NHibernate's AutoMapper handle Interface types?

I typed this simplified example without the benefit of an IDE so forgive any syntax errors. When I try to automap this I get a FluentConfigurationException when I attempt to compile the mappings - "Association references unmapped class IEmployee." I imagine if I were to resolve this I'd get a similar error when it encounters the ...

Automapper Convention

Is is possible with Automapper to setup a convention so that maps do not have to be created by hand for situations where the entity you are mapping to just has say "ViewModel" appended. As an example I would rather not have to setup the following map: Mapper.CreateMap<Error, ErrorViewModel>(); I understand if projection is required t...

Automapper Custom Mapping Exception

Update 1-13-10 I've been able to find some success using the code below for mapping. I am essentially ignoring any of the properties that do not have a mapping and mapping them afterwards. I would appreciate feedback as to whether or not I am going about this in the best way possible. In addition, I am not sure how to go about unit testi...

Reusing validation attributes in custom ViewModels

Hi, When I started using xVal for client-side validation, I was only implementing action methods which used domain model objects as a viewmodel or embedded instances of those objects in the viewmodel. This approach works fine most of the time, but there are cases when the view needs to display and post back only a subset of the model'...