Filter query

1

How to insert a filter in my query the command is in a repository and I want to insert a filter in it, it can be by name for example.

Code:

public IList < T > Consultar() {
using(ISession session = FluentnHibernateHelper.OpenSession()) {
 return (from e in session.Query < T > () select e).ToList();
}
}
    
asked by anonymous 27.09.2017 / 16:34

1 answer

0

You can enter the filtered values in another list.

var suaListaAux = suaLista.Where(a => a.AtributoASerComparado == variavel ).ToList();

Being:

suaLista = List to be filtered
suaListaAux = List that will receive filtered value
AtributoASerComparado = Return value you want to compare
variavel = variable that receives the value that will be used to purchase

This will filter your list to show only the values that have what you want.

    
27.09.2017 / 18:14