I have a table
ErrorsProduction_Registros
that links to another table called
ErrorsProducao_Tipos.
I need to perform dynamic filters in the ErrorsProductionRegister table using lambda expressions.
If I run 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 of the data in the ErrorsProduction_Types table for the database relationship, however, I have some questions about 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();
}
But this last demonstrated way, I no longer have access to the object of the ErrorsProducao_Tipos table.
How do I proceed?