automapper

AutoMapper Collections

I'm trying to map an array into an ICollection of type <T>. Basically I want to be able to do: Mapper.CreateMap<X[], Y>(); Where Y is Collection<T> Any ideas? Thanks. ...

Automapper Mapping

I'm trying to map an object with property names like so: Property_One -> PropertyOne ... etc Sample_Property -> SampleProperty Is there a better way to do this than to map individually each property to another? The only difference is the underline. ...

Is there a Fluent NHibernate Automapping sample project that "just works"?

I just started looking a NHibernate this week, and would love to use the Automapping approach on my current project. I'm working with Fluent NHibernate 1.0.0.594, which I downloaded a few days ago. I found the Examples.FirstProject in the NHibernate source code, which uses the older style entity mapping. This has been tremendously val...

Fluent NHibernate AutoMapping throws "StaleStateException" when try to Commit a List<>

The following code throws a StaleStateException exception when the Order.OrderItems property (an IList) is Commited. The full text of the exception is: An unhandled exception of type 'NHibernate.StaleStateException' occurred in NHibernate.dll Additional information: Unexpected row count: 0; expected: 1 I've just started using NHibern...

Automapper Formatter not working

I'm trying to add a formatter to my Automapper configuration to style all DateTime? fields. I've tried adding my formatter globally: Mapper.AddFormatter<DateStringFormatter>(); And on the specific mapping itself: Mapper.CreateMap<Post, PostViewModel>() .ForMember(dto => dto.Published, opt => opt.AddFormatter<DateStringFo...

Automapper (c#) - Using the instance version of CreateMap and Map with a WCF service???

Hi there, Been having some real issues with automapper, i think i have found the solution but unsure of how to implement it.. basically i am using a custom mapping with ResolveUsing and ConstructedBy to pass in params to the constructor, i understand that most people set this up in the global.asax once and forget about it.. But the pr...

AutoMapper: value factory (setup customer value creation using DI container)

Suppose I have this: public class CustomerViewModel { public CustomerViewModel(ICountryRepository countryRepository) { } } public class AddressViewModel { public AddressViewModel(ICountryRepository countryRepository) { } } Now, I want to map it: AutoMapper.Mapper.CreateMap<A...

Getting at ViewData.Model from spark template post

I am trying to convert my spark views to use ViewData.Model instead of the namevaluecollection so that I can use AutoMapper to map my dto's to entities before it gets into my action method. I can access the viewdata.model from the view, but upon posting back the data, viewdata.model is null. here is some sample code: in my view: <view...

How do you automap List<float> or float[] with Fluent NHibernate?

Having successfully gotten a sample program working, I'm now starting to do Real Work with Fluent NHibernate - trying to use Automapping on my project's class heirarchy. It's a scientific instrumentation application, and the classes I'm mapping have several properties that are arrays of floats e.g. private float[] _rawY; ...

asp.net mvc automapper parsing

let's say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; set;} public SelectList Countries {get; set;} } can automapper be used to perform to parse from Person into PersonViewModel and back ? ...

Using AutoMapper (by Jimmy Bogard) with NHibernate

I'm trying to use AutoMapper to map from DTO's to my Domain. My DTO's might look like this: public class MyDTO { public string Name { get; set; } public bool OtherProperty { get; set; } public ChildDTO[] Children { get; set;} } public class ChildDTO { public string OtherName { get; set; } } My Domain objects like th...

DTO/Command Pattern Question

There was a very interesting discussion on LosTechies regarding AutoMapper(an argument for/against 2-way mapping). This actually caught my attention due to the problem I'm currently working through. I'm working on a shipment piece to provide information such as rates/delivery times to my users. To centralize the actual services, I have ...

Inject AutoMapper

I have been working on injecting AutoMapper into controllers. I like the implementation of Code Camp Server. It creates a wrapper around AutoMapper's IMappingEngine. The dependency injection is done using StructureMap. But I need to use Castle Windsor for my project. So, how do we implement the following dependency injection and set-up u...

MVC - Model View inside of another Model View

Is it good practice to use one model view inside of another one and how will AutoMapper work with it? Example: public class CustomerModelView { public string FullName {get;set;} public string IList<OrderListModelView>(get;set;) } ...

Problem with AutoMapper in IIS7 when using signed assemblies

I am trying to use AutoMapper with web application running on IIS 7. The intended use it so map domain types defined in an external dll to view models defined in the IIS application. This works fine except when the external dll is singed. Then I get the following error: AutoMapper.AutoMapperMappingException was unhandled by user code...

Automapper, generics, dto funtimes

Here's the deal: I have a report designer where users can create reports based on some predefined datasets. They can select a set of columns to include in the report and then, when the report is ran, an IList is created by mapping the NHibernate collection over to the dto class collection using automapper. The problem with this is tha...

What's wrong with my AutoMapper Customer ValueResolver Hook?

I have the following hook in my Global.aspx protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); AutoMapper.Mapper.CreateMap<FormCollection, Models.IAmACustomer>().ForAllMembers(form => form.ResolveUsing<Models.FormCollectionValueResolver<Models.IAmACustomer>>()); } In ...

Simple Convention Automapper for two-way Mapping (Entities to/from ViewModels)

UPDATE: this stuff has evolved into a nice project, see it at http://valueinjecter.codeplex.com check this out, I just wrote a simple automapper, it takes the value from the property with the same name and type of one object and puts it into another, and you can add exceptions (ifs, switch) for each type you may need so tell me what do...

C# automapper nested collections

Hi guys, I have a simple model like this one: public class Order{ public int Id { get; set; } ... ... public IList<OrderLine> OrderLines { get; set; } } public class OrderLine{ public int Id { get; set; } public Order ParentOrder { get; set; } ... ... } What I do with Automapper is this: Mapper.CreateMap<Order,...

Configuring Automapper in Bootstrapper violates Open-Closed Principle?

I am configuring Automapper in the Bootstrapper and I call the Bootstrap() in the Application_Start(), and I've been told that this is wrong because I have to modify my Bootstrapper class each time I have to add a new mapping, so I am violating the Open-Closed Principle. How do you think, do I really violate this principle? public sta...