I have the following classes:
public class Pessoal
{
public int ID { get; set; }
public string CPF { get; set; }
public string PIS { get; set; }
public string NOME { get; set; }
...
...
...
}
public class Dominio : DominioBase
{
public Pessoal Pessoal { get; set; }
public Pessoal PessoalAlteracao { get; set; }
}
I would like to copy the attributes of PessoalAlteracao
to the values of Pessoal
, but only how much value of the PessoalAlteracao
attribute is equal to null
.
I can do this through if
:
PessoalAlteracao.CPF = PessoalAlteracao.CPF == null ? Pessoal.CPF : PessoalAlteracao.CPF;
But I would like to use a simpler form, how would I create a loop , by the attributes and even test the values?