1
In my project, I have a type of heritage that I have mastered by TPT. Analyzing the documents and several examples I can’t identify where I’m going wrong, because the mapping is apparently correct, the definitions of the classes, everything.
Problem: I have three classes: Person, Client and Broker. Client and Broker inherit from Person and so is in the mapping. When in the system I do any search using the Dbset of the subclasses, the query that Identity assembles is searching from the parent class, that is, if I did a search using the Client type, Identity assembles a query from the superclass (Person) and not from the subclass (Client).
public abstract class Pessoa
{
public Pessoa()
{
}
public string Nome { get; set; }
public string NumeroCpfCnpj { get; set; }
public string NumeroRgIe { get; set; }
public string FlagEstadoCivil { get; set; }
public string Profissao { get; set; }
public DateTime DataDeNascimento { get; set; }
public string TelefoneFixo { get; set; }
public string TelefoneCelular { get; set; }
public string Fax { get; set; }
public string Endereco { get; set; }
public string Numero { get; set; }
public string Complemento { get; set; }
public string NomeMae { get; set; }
public string NomePai { get; set; }
public string NomeConjuge { get; set; }
public DateTime DataNascimentoConjuge { get; set; }
public DateTime DataCasamento { get; set; }
public string Email { get; set; }
public float RendaFamiliar { get; set; }
public string Bairro { get; set; }
public string CEP { get; set; }
public int? CidadeId { get; set; }
public string Observacoes { get; set; }
public int RegimeCasamentoId { get; set; }
public int EstadoCivilId { get; set; }
public bool IsDeleted { get; set; }
public DateTime DataEmissao { get; set; }
public string OrgaoEmissor { get; set; }
public string EstadoEmitente { get; set; }
public Sexo Sexo { get; set; }
}
public class Cliente : Pessoa
{
public Cliente()
{
FlagMauPagador = false;
StatusCobrancaId = 1;
FlagImpedirRealizarVenda = false;
FlagImpedirGerarBoleto = false;
FlagImpedirSairNoRelatorioCobranca = false;
}
public bool FlagMauPagador { get; set; }
public int StatusCobrancaId { get; set; }
public bool FlagImpedirRealizarVenda { get; set; }
public bool FlagImpedirGerarBoleto { get; set; }
public bool FlagImpedirSairNoRelatorioCobranca { get; set; }
}
public class Corretor : Pessoa
{
public Corretor()
{
Produtos = new List<Produto>();
Loteamentos = new List<Loteamento>();
}
public int CodCorretor { get; set; }
public string NomeCorretor { get; set; }
public string Creci { get; set; }
public decimal ValorDescontoMaximo { get; set; }
public int? IdParceiroVenda { get; set; }
public bool flgAtivo { get; set; }
public ICollection<Produto> Produtos { get; set; }
public ICollection<Loteamento> Loteamentos { get; set; }
}
public class PessoaConfiguration : EntityTypeConfiguration<Pessoa>
{
public PessoaConfiguration()
{
ToTable("pessoa");
HasKey(c => c.Id);
Property(c => c.Id)
.HasColumnName("cod_pessoa")
.IsRequired();
[...]
}
}
public class CorretorConfiguration : EntityTypeConfiguration<Corretor>
{
public CorretorConfiguration()
{
ToTable("corretor");
[...]
}
}
public class ClienteConfiguration : EntityTypeConfiguration<Cliente>
{
public ClienteConfiguration()
{
ToTable("cliente");
[...]
}
}
How is your setup
DbContext
Put the whole class in question? and its classes also and which code is performing the research?– novic
And the queries and the Dbcontext????
– novic