0
I have a table
Errosproducao_records
linked to another table called
Errosproducao_tipos.
I need to perform dynamic filters in the table Errors_records using lambda expressions.
if I perform the filters like this:
List<ErrosProducao_Registros> list = db.ErrosProducao_Registros.ToList();
//filtra o tipo de erro
if (codTipoErro >= 0)
list = list.Where(e => e.CodTipoErro == codTipoErro);
my variable list still has all the data from the table Errosproducao_types by the database relation, however, I have doubts about the performance using this method.
Today I do as below:
using (DB_VISTA_RECORTEEntities db = new DB_VISTA_RECORTEEntities())
{
IQueryable<ErrosProducao_Registros> result = db.ErrosProducao_Registros;
//filtra o tipo de erro
if (codTipoErro >= 0)
result = result.Where(e => e.CodTipoErro == codTipoErro);
List<ErrosProducao_Registros> list = result.ToList();
}
However, this last demonstrated way I no longer have access to the table object Errosproducao_types.
How should I proceed?
Ever tried to use a
Include
?, or else inSelect
get what you need? the Second way is the ideal, because it only brings what you need from your tables!– novic