객체의 속성을 다른 속성 이름을 가진 다른 객체에 어떻게 매핑합니까? ValueInjecter를 사용하여 다른 속성 이름을 갖는 객체 간 매핑
나는이처럼 보이는Product
클래스가 :
public class Product : IEntity
{
public int Id { get; set; }
public string Name { get; set; }
}
과 같은 뷰 모델은 같습니다
Product.Id => ProductSpecificationAddViewModel.ProductId
Product.Name =>ProductSpecificationAddViewModel.ProductName
: 나는 다음과 같은 매핑을 할 필요가
public class ProductSpecificationAddViewModel
{
public int ProductId { get; set; }
public string ProductName { get; set; }
}
여기 내 행동 방법입니다 :
public ActionResult Add(int id)
{
Product product = productService.GetById(id);
// Mapping
//ProductSpecificationAddViewModel viewModel = new ProductSpecificationAddViewModel();
//viewModel.InjectFrom(product);
return View(viewModel);
}
어떻게하면됩니까?
현재 전 세계 어디에서나 ConventionInjection을 찾을 수 없습니다. –