I am a first-time sailor with EntityFramework and am working with a USUARIO
class that inherits from PESSOA
.
There are other classes like PESSOATIPO
, PESSOAFISICA
, PESSOAJURIDICA
, etc., the problem is that when I load my DataGridView
, EntityFramework can not separate the data from each table and position the fields correctly inside of the lines. See how PESSOAFISICA
should be displayed the fields NOMECOMPLETO
, APELIDO
E DATANASCIMENTO
.
This is because I have a generic function that returns everything to me. I would like to know if you can implement / change the function below to pass some kind of select
( Lambda
) to it to return columns in the order I want, so DataGridview
loaded correctly and the load has a good performance?
Example:
Usuario.Select(x=> x.USuarioId,
x.PessoaFisica.NomeCompleto,
x.PessoaFisica.Apelido,
x.PessoaFisica.DataNascimento).
or something like that.
public List<TEntity> GetAll(Expression<Func<TEntity, bool>> Predicate)
{
var query = Context.Set<TEntity>().Where(Predicate).ToList();
return query;
}