How do I unflatten?

39 views
Skip to first unread message

AndrewOz

unread,
Sep 3, 2009, 2:50:14 PM9/3/09
to AutoMapper-users
Is it supported?

Mapper.CreateMap<ClassC, ClassD>(); // <<== this works
(flattening)
Mapper.CreateMap<ClassD, ClassC>(); // <<== this doesn't
work (unflattening)

Mapper.AssertConfigurationIsValid(); // <<== throws
exception complaining about second mapping

public class ClassA
{
public int One;
public string Two;
}

public class ClassC
{
public int FieldA;
public string FieldB;
public ClassA FieldC;
}

public class ClassD
{
public int FieldA;
public string FieldB;
public int FieldCOne;
public string FieldCTwo;
}

AndrewOz

unread,
Sep 3, 2009, 5:04:40 PM9/3/09
to AutoMapper-users
ok, well, I answered my own question.

Add a GetFieldC() method to ClassD. Although it would be nice if
AutoMapper would automagically reverse the flattening using the
reverse logic of flattening.

Cheers.

AndrewOz

unread,
Sep 3, 2009, 5:47:13 PM9/3/09
to AutoMapper-users
But that doesn't work when you don't want the two class "hierarchies"
to know about the other.

I guess I'm stuck with MapFrom()... not so elegant.

Jimmy Bogard

unread,
Sep 3, 2009, 6:46:06 PM9/3/09
to automapp...@googlegroups.com
Yes, not so elegant right now.  This is coming up too much for me to ignore...but for v1, I don't see it making it in.  I'm looking to drop a V1 in the next month or so, and this is one of the top features I'm looking at for V2.  The semantics for reverse mapping are completely different than flattening, so I'll likely have to do some exploration work in that area to figure out the right model.

Thanks,

Jimmy

AndrewOz

unread,
Sep 8, 2009, 10:40:14 AM9/8/09
to AutoMapper-users
That's good news. I'm more than happy to help out or beta test if
you'd like.

healing...@hotmail.com

unread,
Sep 16, 2016, 10:36:13 PM9/16/16
to AutoMapper-users
Was anything ever implemented to support something like this?  I've tried looking around the forums, but have not found anything...

Jimmy Bogard

unread,
Sep 17, 2016, 1:07:32 AM9/17/16
to automapper-users
Nope.

--
You received this message because you are subscribed to the Google Groups "AutoMapper-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automapper-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages