我有以下型号:
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; }
}
我的视图模型:
public class PersonDetailsViewModel
{
public string Name { get; set; }
public IEnumerable<HttpPostedFilebase> ProfileImages { get; set; }
}
现在我的问题是,如何使用自动映射器映射它们?我的意思是 ProfileImage 还需要 PersonId(可以在插入时由实体框架插入)。我需要更改ViewModel中的命名吗?