1
I have a table Person who has one-to-one relationship with the tables PessoaFisica
and PessoaJuridica
.
When I pass the id, it has to check me if nature is physical or legal and bring me the person + pessoafisica
or pessoajuridica
(The person can only be one of the two). How do I mount a lambda expression for this? Below, I have one that I’m trying to ride:
public Pessoa GetJoinById(int id)
{
var pessoa = Db.Pessoa.FirstOrDefault(x => x.Id == id);
//.Include("")
//.Include("")
pessoa.(x =>
{
if (x.PessoaNatureza == PessoaNatureza.Fisica)
{
Db.Entry(x)
.Reference(f => f.PessoaFisica)
.Load();
}
else
{
Db.Entry(x)
.Reference(j => j.PessoaJuridica)
.Load();
}
});
return null;
}
It was I who posted this in another question but, it’s different, it’s wrong this! What is your doubt?
– novic
Yes, Virgilio. I think it was you... In that case, I was trying to send a list and it worked 100% I need to adapt for him to do the same, only sending only one person.... I don’t know how to lick.. Only sql....
– Master JR