Matthew Nichols
Matthew Nichols

Reputation: 5035

Can AutoMapper do the opposite of flatening (flat to nested structure) in a conventional way?

Just looking to confirm a general question that I haven't seen addressed so I have not included any code. I use AutoMapper regularly to map back and forth between my domain objects and my DTO/viewmodels and I often take advantage of the conventional automatic mapping of nested objects and properties in the source to a flattened structure in the destination. I just assumed that the same would be the case going from flat source to nested destination, but it doesn't appear to be true. Is this correct or am I missing something?

I am clear I can explicitly map it and will do so, but less code is better so I wanted to check. Have googled a bit on this and I don't find much reference to going from flat to nested. I am using AutoMapper 2.0.

Thanks, Matthew

Upvotes: 3

Views: 760

Answers (1)

Daniel Schilling
Daniel Schilling

Reputation: 4967

To my knowledge, no, it can't do that (though proving a negative is always difficult).

If you need this functionality, you should check out ValueInjecter. It's a convention based object mapper that can flatten, unflatten, and a whole slew of other ridiculously powerful things (like calling stored procedures).

Upvotes: 2

Related Questions