2
I have a base class:
public class MinhaClasse<T> : Controller where T : class
{
public List<T> BuscarVarios(string nome)
{
return db.Set<T>().Where(/*?????*/);
}
}
How do I use the cloister Where when my class is dynamic?
2
I have a base class:
public class MinhaClasse<T> : Controller where T : class
{
public List<T> BuscarVarios(string nome)
{
return db.Set<T>().Where(/*?????*/);
}
}
How do I use the cloister Where when my class is dynamic?
2
Although I can’t see a reason to do so. The most I can think of right now to solve this problem is to ask for a Func<T, bool> instead of a string.
See in practice
public class MinhaClasse<T> : Controller where T : class
{
public List<T> BuscarVarios(Func<T, bool> filtro)
{
return db.Set<T>().Where(filtro).ToList();
}
}
When using you would do
minhaClassePersonalizada.BuscarVarios(x => x.Nome == "Joaquim");
Browser other questions tagged c# .net
You are not signed in. Login or sign up in order to post.
Welcome to [en.so]. Your question is very vague. Please click on [Edit] and put more details so we can help you.
– Jéf Bueno
It’s true @jbueno .
– Danilo Pádua