2016-08-17 7 views
0

이 코드가 : 나는 모든 것이 작동 한ValueInjecter 사용자 정의 매핑

Mapper.AddMap<Product, DetailsVM>(src => 
{ 
      var res = new DetailsVM(); 
      res.InjectFrom(src); // maps properties with same name and type 
      res.test = "asd"; 
      return res; 
    }); 

    productVM.InjectFrom(test); 

을이 내 VM입니다 :

public int ProductId { get; set; } 
public decimal Cost { get; set; } 
public decimal UnitPrice { get; set; } 
public int OnHandQty { get; set; } 

public ProductPicture thumb { get; set; } 
public ProductPicture main { get; set; } 

public string test { get; set; } 

실제 모델이없는 속성 test, 나는 단순히 test을 임의의 문자열로 설정하려고합니다. 어떻게해야합니까? 내가지도를 만들려고 할 때마다 나는 계속 null을 얻는다.

답변

1

당신은 InjectFrom

+0

당신이 작업을 수행하는 방법의 샘플을 가지고 있습니까 Mapper.AddMap의 영향을받지 않는 대신 InjectFromMapper.Map를 호출 할 필요가? –

+0

샘플은 https://github.com/omuleanu/ValueInjecter에 있습니다. – Omu