I need to make a join between the person and person tables so that the Entity Framework core brings a corresponding record. I'll be clearer:
In the Person Person table, I classify my people record using an enum. I did this to save the Ids of each register (Person, Customer, Vendor, etc). If a person is a customer, they will have an ID, if they are a Vendor, they will have another ID and if they are neither, they will have their ID.
Atthemoment,Ineedtogiveagetinthebankandbringallpeoplethatarephysical/legalandthatareoftypePERSON.SoIneedtogiveajoininthePersonEntitytableandmakeawherereportingtobringonlyoftype0-PERSON.HowdoIdothisusingLINQ?
publicIQueryable<Pessoa>GetJoinAll(){varpessoas=Db.Pessoa.Include("PessoaEntidade")
.Include("Filial")
.ToList();
pessoas.ForEach(x =>
{
if (x.PessoaNatureza == PessoaNatureza.Fisica)
{
Db.Entry(x)
.Reference(f => f.PessoaFisica)
.Load();
}
else
{
Db.Entry(x)
.Reference(j => j.PessoaJuridica)
.Load();
}
});
return pessoas.AsQueryable();
}