1
im有點新有價值的注射器,對整個對象映射到世界實物。似乎價值投資者是目前最好的選擇之一。我想知道什麼是映射的最佳途徑這類對象的ValueInjecter體系結構建議
基本上我想要的是從視圖模型
public class RegisterModel
{
[Required]
[DataType(DataType.EmailAddress)]
[Display(Name = "Email address")]
public string Email { get; set; }
[Required]
[ValidatePasswordLength]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
[Required]
[StringLength(255)]
[Display(Name = "First Name")]
public string FirstName { get; set; }
[Display(Name = "Middle Name")]
public string MiddleName { get; set; }
[Required]
[StringLength(255)]
[Display(Name = "Last Name")]
public string LastName { get; set; }
}
映射值到我的域實體
public class UserInfo : EntityBase
{
public UserInfo()
{
PersonName = new PersonName();
}
public virtual string Email { get; set; }
public virtual string Password { get; set; }
public virtual PersonName PersonName { get; set; }
}
public class PersonName
{
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string Fullname1
{
get { return string.Format(@"{0}, {1} {2}", LastName, FirstName, MiddleName); }
}
public string Fullname2
{
get { return string.Format(@"{0} {1} {2}", FirstName, MiddleName, LastName); }
}
}
我想這碼它的工作原理,但不知道它是否是最好的方法
var newuserinfo = new UserInfo();
newuserinfo.InjectFrom(model);
newuserinfo.PersonName.InjectFrom(model);
並且對象-t o-對象映射框架就像價值觀看者適合系統架構?我想寫一個單元測試我的對象映射。