How to use Automapper with uploaded images in complex types (MVC + entity framework)

akafurious

New Member
I've got the following models:\[code\]public abstract class PersonBase : EntityWithTypedId { public PersonBase() { this.ProfileImages = new List<ProfileImage>(); } public string name; [Required] public string Name { get { return name; } set { name = value; this.UrlFriendlyName = value.ToUrlFriendly(); } } public string UrlFriendlyName { get; protected set; } [UIHint("UploadImage")] public List<ProfileImage> ProfileImages { get; set; } }public class ProfileImage { public int PersonId { get; set; } public byte[] Image { get; set; } }\[/code\]And my viewmodel:\[code\]public class PersonDetailsViewModel { public string Name { get; set; } public IEnumerable<HttpPostedFilebase> ProfileImages { get; set; } }\[/code\]Now my question is, how can I map those with automapper? I mean the ProfileImage also needs the PersonId (which could be inserted by the Entity Framework on insert). Do I need to change the naming in the ViewModel or?
 
Back
Top