automapper

Can I configure AutoMapper to read from custom column names when mapping from IDataReader?

Psuedo code for mapping configuration (as below) is not possible since the lambda only lets us access Type IDataReader, wheras when actually mapping, AutoMapper will reach into each "cell" of each IDataRecord while IDataReader.Read() == true: var mappingConfig = Mapper.CreateMap<IDataReader, IEnumerable<MyDTO>>(); mappingConfig.ForMembe...

AutoMapping custom Generic Types - How?!

hey guys, I'm using automapper version 1.1.0.188 In my AutoMapper.Configure I'm mapping Entities to DTOs and vice versa, like so: // entity >> DTO Mapper.CreateMap<MetaTemplate, MetaTemplateDTO>(); Mapper.CreateMap<Person, PersonDTO>(); // DTO >> Entity Mapper.CreateMap<MetaTemplateDTO, MetaTemplate>(); Mapper.CreateMap<PersonDTO...

After using Automapper to map a ViewModel how and what should I test?

I am attempting to test the Index action of a controller. The action uses AutoMapper to map a domain Customer object to a view model TestCustomerForm. While this works I am concerned about the best way to test the results that I am receiving from the Index action. The controller's index action looks like this: public ActionResult Index...

Automapper null properies

Hello guys. I map my objects to dtos with Automapper. public class OrderItem : BaseDomain { public virtual Version Version { get; set; } public virtual int Quantity { get; set; } } [DataContract] [Serializable] public class OrderItemDTO { [DataMember] public int Id { get; set; } [DataMember] public string Gui...

How do I map an inheritance hierarchy with Automapper?

I have the following example classes being used in an MVC/MVVM type app: class A { public string Property1 { get; set; } } class B : A { public string Property2 { get; set; } } class ViewModel { public string Property1 { get; set; } public string Property2 { get; set; } } A is my base class and B is the derived class. Vi...

Where should I put my CreateMap calls for AutoMapper?

I'm creating WCF services that return data contract types by mapping Entity Framework types. What is the best place to put the Mapper.CreateMap calls? Should I do it in each service and only for that service, or should I do it on service startup? Thoughts? ...

How do I use AutoMapper to populate back to a DataTable?

I'm using AutoMapper which is a great tool. There's lots of examples converting from DataTable/IDataRead to DTO's but I can't seem to find any that convert the DTO back to a DataTable. Is this possible? I've tried various things, but I think there's some difficulty with the creation of Rows - as you can't new them up. ...

Using AutoMapper to unflatten a DTO

I've been trying to use AutoMapper to save some time going from my DTOs to my domain objects, but I'm having trouble configuring the map so that it works, and I'm beginning to wonder if AutoMapper might be the wrong tool for the job. Consider this example of domain objects (one entity and one value): public class Person { public st...

AutoMapper Exclude Fields

I'm trying to map one object to another but the object is quite complex and so during dev I'd like the ability to either exclude a bunch of fields and get to them one by one or to be able to specify to map only fields I want and increase that as each test succeeds. So; class string field1 string field2 string fi...

AutoMapper Ignore an item in a collection based on a property value in the source

I'm mapping an ApplianceViewModel to a ApplianceDTO. Each Appliance has a collection of ActionViewModels which are mapped to ActionDTO. What I'd like to do is configure the mapper to ignore ActionViewModels whose IsPersisted value is False. My ViewModel classes ... public interface IApplianceViewModel : INotifyPropertyChanged { Obs...

Fluent nhibernate automapping collection

Hi, I am trying to map my collections with FNHib automapping. The problems that I want to solve are: 1) I want all my collections in the project to be mapped via private field. How can I say that globally? 2) Is there any way to automap bidirectional relationship without explicitly overriding each of my entities. class OrganizationEnt...

How can I use AutoMapper on properties marked Internal?

I have a solution with several projects. A business components project, an MVC web app, a DTO's and ViewModels project, a business component unit test project, and an MVC unit test project. All in all, not too unusual. The business component had a Service reference to several WCF endpoints. Within the business component, the data contra...

Is AotoMapper Supported Complex Class Structure?

I have a problem when I try to map following class. class LazyStudent : ActiveRecordBase { [Property] public String Name { set; get; } [HasMany(typeof(LazyStudentBook))] public IList<LazyStudentBook> Books { set; get; } } class LazyStudentBook : ActiveRecordBase { [...

automapper + lazy loading + mvc contrib grid + s#arp repositories

Hi, I am using the nice s#arp repositories and the paging extension method plus sorting like this: public ViewResult Index(int? page, GridSortOptions sort) { ViewData["sort"] = sort; if (!string.IsNullOrEmpty(sort.Column)) { return View(this.LabService.GetAllLabs().OrderBy(s...

Automapper: How do you map a type that is conditional?

Greeting Gurus, So basically I have this a Map that I setup for use for TripFeeSchedule, trip fee schedule is a IEnumerable type. I am trying to map this so I dont have to have 5 or so ValueResolvers, and I am stuck. What i basically want to do is map a type of OPtional fee from a single fee schedule. So for example if the type is a la...

Automapper for Java

Is there Java equivalent of .Net's Automapper? ...

Mapping only few properties instead of all using Automapper

Hi guys, I have recently started using automapper and it has work fine for me so far. I have been mapping domain objects to corresponding dtos and by default all source properties get mapped to their matching destination properties. I have been using code as follows: Mapper.CreateMap<Node, NodeDto>(); var nodeDto = Mapper.Map<Node, No...

Issue with Ignoring nested Properties using Automapper

Hi guys, I have ran into an issue where I am trying to ignore properties within properties. e.g. Mapper.CreateMap<Node, NodeDto>() .ForMember(dest => dest.ChildNodes, opt => opt.Ignore()) .ForMember(dest => dest.NodeType.EntityType.Properties, opt => opt.Ignore()); I get following exception: {"Express...

Issue with ignoring base class property in child classes mappings using Automapper

Hi guys, I have a scenario where I would like to ignore some properties of classes defined in base class. I have an initial mapping like this Mapper.CreateMap<Node, NodeDto>() .Include<Place, PlaceDto>() .Include<Asset, AssetDto>(); Then I customised it more like this to ignore one of the propertie...

Need help with a 'No persister for:' exception with Fluent Nhibernate Automapping

Hello I'm having some problems with applying NHibernate Fluent Automapping. It worked great in a test project. But now.. Test method [PROJECTNAME].SubscriptionTest.SubscriptionConstructorTest threw exception: NHibernate.MappingException: No persister for: [PROJECTLIB].SubscriptionManagerRP The class (then again, the same exception a...