Possible to create a convention to map collections of viewmodels

Sep 17, 2011 at 7:52 PM

I have entity objects and viewmodels that look like this:

public class CompanyEntity
{
    public int Id { get; set; }
    public List<PhoneNumber> PhoneNumbers { get; set; }
}

public class CompanyViewModel
{
    public int Id { get; set; }
    public List<PhoneNumberViewModel> PhoneNumbers { get; set; }
}

Would it be possible to perform a single mapping of CompanyEntity to CompanyViewModel and have the PhoneNumbers collections get mapped in the process? I'd like to match based on the convention of [Classname] => [Classname]ViewModel.

I played around with a convention but couldn't get far. I couldn't figure out how to trigger the match based on the type of the collection, then couldn't figure out how to perform a new mapping of the enumerable in the SetValue method. I was hoping to avoid having to do a new injection for those properties.

Oct 2, 2011 at 5:57 AM

joshtpllc, My post might help your situation...

http://valueinjecter.codeplex.com/discussions/274484