automapper

Mock AutoMapper Mapper.Map call using Moq

Whats the best way to setup a mock expection for the Map function in AutoMapper. I extract the IMapper interface so I can setup expects for that interface. My mapper has dependencies, so I have to pass those in to the mapper. What happens when I create 2 instances of my mapper class, with 2 different dependency implementations? I asume...

Override for fluent NHibernate for long text strings nvarchar(MAX) not nvarchar(255)

When ever you set a string value in fluent NHibernate it alwasy sets the DB vales to Nvarchar(255), I need to store quite a lot of long string which are based on user inputs and 255 is impractical. Just to add this is an issue with the automapper as I am using fluent NHibernate to build the database. ...

Where to put automapper configuration for webservice?

I read that a web service does not have a global.asax to configure global settings (like the automapper configuration). So my question is: Should I put the automapper configuration in every webmethod or is there a place I can put it globally? I'm going to call the webservice of couple of thousand times every night so I'm worried that i...

Does AutoMapper support ReadOnlyCollections?

I have tried various configurations, but cannot get it working. I am wondering if it is supported? ...

Automapper: Update property values without creating a new object

How can I use automapper to update the properties values of another object without creating a new one? ...

Mapping all properties of 'X' type with AutoMapper

I've just started using AutoMapper and so far found it very straight-forward and time-saving. Just one thing I'm not sure about - how do I map all the properties of a given type in the same way? Can this be done with AutoMapper in a single statement, using a lambda, as with regular mapping? ...

What is the correct url for checking out AutoMapper from googlecode?

I am referring to this project by Jimmy Bogard: http://www.codeplex.com/AutoMapper The code repository site is: http://code.google.com/p/automapperhome/source/checkout The instructed checkout command is: svn checkout http://automapperhome.googlecode.com/svn/trunk/ automapperhome-read-only This does not work. I have tried SlikSVN, To...

IoC with AutoMapper Profile using Autofac

I have been using AutoMapper for some time now. I have a profile setup like so: public class ViewModelAutoMapperConfiguration : Profile { protected override string ProfileName { get { return "ViewModel"; } } protected override void Configure() { AddFormatter<HtmlEncode...

AutoMapper and is*Specified properties

Hi, I have a bunch of XSD.exe-generated data contract classes which for all optional elements have a pair of C# properties like int Amount {get; set;} bool isAmountSpecified {get; set;} On the other side of mapping arena I have a nullable int like int? Amount {get; set;} Ideally I'd like for AutoMapper to be able to recognize such...

AutoMapper and Linq expression.

I am exposing the Dto generated from AutoMapper to my WCF services. I would like to offer something like that from WCF: IList GetPersonByQuery(Expression> predicate); Unfortunately I need back an expression tree of Person as my DAL doesn't know the DTO. I am trying this wihtout success: var func = new Func<Person, bool>(x => x.F...

Can I Automap a tree hierarchy with Fluent NHibernate?

Is it possible to auto map a simple nested object structure? Something like this: public class Employee : Entity { public Employee() { this.Manages = new List<Employee>(); } public virtual string FirstName { get; set; } public virtual string LastName { get; set; } public virtual bool IsLineManager { get; s...

AutoMapper Mapping IEnumerable to DataReader Issue

I am using AutoMapper to datareader using code as discussed below http://elegantcode.com/2009/10/16/mapping-from-idatareaderidatarecord-with-automapper/ I see it being very flakky...and unpredictable. 1) Same code with same datareader at times brings value back to the dto result set and at times doesnot. 2) I have an ID value coming fr...

AutoMapper bidirectional mapping

If I want to do bi-directional mapping, do I need to create two mapping? Mapper.CreateMap<A, B>() and Mapper.CreateMap<B, A>()? ...

How do I get AutoMapper to map this?

Say I have this class: public class Account { public int AccountID { get; set; } public Enterprise Enterprise { get; set; } public List<User> UserList { get; set; } } When I use AutoMapper to map the Account class, I would also like it to map the Enterprise class, and the list of users (UserList) in the returned object. Ho...

AutoMapper Problem - List won't Map

I have the following class: public class Account { public int AccountID { get; set; } public Enterprise Enterprise { get; set; } public List<User> UserList { get; set; } } And I have the following method fragment: Entities.Account accountDto = new Entities.Account(); DAL.Entities.Account account; Mapper.CreateMap<DAL.Ent...

automapper - how to map object list

Let us say my domain object can contain a bunch of objects like this: List<Thing> Things where Thing is defined like this: class Thing ( public int ThingId { get; set; } public string ThingName { get; set; } ) My DTO contains List<string> ThingIds; List<string> ThingNames; The question is how can I use automapper to map ...

How to register a custom ObjectMapper with AutoMapper

I am planning to create my Own Custom Object Mapper for a type using AutoMapper's IObjectMapper interface, but i don't see any place where we can register the implemented mapper with AutoMapper. Could anyone tell me how to register it. Edit: For more information on this please follow the discussion at AutoMapper-Users group ...

Automapper: Ignore on condition of

Is it possible to ignore mapping a member depending on the value of a source property? For example if we have: public class Car { public int Id { get; set; } public string Code { get; set; } } public class CarViewModel { public int Id { get; set; } public string Code { get; set; } } I'm looking for something like Mapper.Creat...

Mapping from different properties based on discriminator value using AutoMapper

I have one very general object that I want to map to a destination type using AutomMapper, but I want to map it to different types depending on the value of a property in the source type. For example, let's say I have: public class Source { public string Discriminator { get; } public string ValueA { get; } public string Valu...

Merge two objects to produce third using AutoMapper

I know it's AutoMapper and not AutoMerge(r), but... I've started using AutoMapper and have a need to Map A -> B, and to add some properties from C so that B become a kind of flat composite of A + C. Is this possible in AutoMapper of should I just use AutoMapper to do the heavy lifting then manually map on the extra properties? ...