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. ...
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. ...
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. ...
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...
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...
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...
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...
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...
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...
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; ...
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 ? ...
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...
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 ...
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...
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;) } ...
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...
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...
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 ...
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...
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,...
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...