After working with AutoMapper, I came across ValueInjecter on this site. I am trying to do this, but I am stuck on what is probably a very simple scenario.
But before I delve into the sample code, does anyone know if ValueInjecter works in a medium trust web environment? (How is Godaddy?)
Ok, on the code! I have the following models:
public class NameComponent
{
public string First { get; set; }
public string Last { get; set; }
public string MiddleInitial { get; set; }
}
public class Person
{
public NameComponent Name { get; set; }
}
what I want to map to the following DTO:
public class PersonDTO : BaseDTO
{
private string _firstName;
public string FirstName
{
get { return _firstName; }
set { NotifyPropertyChanged(() => FirstName, ref _firstName, value); }
}
private string _middleInitial;
public string MiddleInitial
{
get { return _middleInitial; }
set { NotifyPropertyChanged(() => MiddleInitial, ref _middleInitial, value); }
}
private string _lastName;
public string LastName
{
get { return _lastName; }
set { NotifyPropertyChanged(() => LastName, ref _lastName, value); }
}
}
, Map from Model to DTO, Model.Name.First → DTO.FirstName
DTO FirstName → Name.First. , Flatten/UnFlatten, , : FirstName ↔ Name.First. First Last , MiddleInitial? Model.Name.MiddleInitial → DTO.MiddleInitial.
, , , , , . - ?