Hi.
I don't know if it's a feature or a bug, but I have an issue that I don't understand why it's happening.
I've an Entity with public getters, private setters and a constructor with parameters:
public class Cargo : Entidade
{
//[...] removed for simplification
public Cargo(int id, string nome, int? cargoChefeId = null) : base(id)
{
_subordinados = new List<Cargo>();
ValidarNome(nome);
ValidarCargoChefe(cargoChefeId);
Nome = nome.Trim().ToUpper();
CargoChefeId = cargoChefeId;
}
public int? CargoChefeId { get; private set; }
public string Nome { get; private set; }
public virtual Cargo CargoChefe { get; private set; }
//[...] removed for simplification
}
And my View Model:
public class CargoModelo
{
public int Id { get; set; }
[Display(Name = "Cargo Chefe")]
public int? CargoChefeId { get; set; }
[Required]
[MinLength(5)]
[MaxLength(100)]
public string Nome { get; set; }
public CargoModelo CargoChefe { get; set; }
}
I wrote this configuration:
TypeAdapterConfig<CargoModelo, Cargo>.NewConfig().MapToConstructor(true);
It works, but, I don't know why, after mapping to constructor, It uses entity private setters, losing the validation and data manipulation done in the ctor.
How can I change this behavior?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4