tags:

views:

77

answers:

0

First time using AutoMapper and I'm have a hard time figuring out how to use it. I'm trying to map a ViewModel to my Database Tables.

My ViewModel looks like this...

   public class AddressEditViewModel
    {
        public AddressEdit GetOneAddressByDistrictGuid { get; private set; }
        public IEnumerable<ZipCodeFind> GetZipCodes { get; private set; }

        public AddressEditViewModel(AddressEdit editAddress, IEnumerable<ZipCodeFind> Zips)
        {
            this.GetOneAddressByDistrictGuid = editAddress;
            this.GetZipCodes = Zips;
        }
    }   

The Mapping I'm trying to use is...

 CreateMap<Address, AddressEditViewModel>();  

When I run this test...

 public void Should_map_dtos()
    {
        AutoMapperConfiguration.Configure();
        Mapper.AssertConfigurationIsValid();
    }  

I get this error...

  AutoMapper.AutoMapperConfigurationException: The following 2 properties on JCIMS_MVC2.DomainModel.ViewModels.AddressEditViewModel are not mapped: 
    GetOneAddressByDistrictGuid
    GetZipCodes
Add a custom mapping expression, ignore, or rename the property on JCIMS_MVC2.DomainModel.Address.

I'm not sure how I am supposed to map those 2 properties. I would appreciate any direction. Thanks

Mark