I would like to know if you can search two types of variables (one at a time) in a single textbox. Example:
public ActionResult Index(string pesquisa)
{
var usuario = from u in db.usuario
select u;
if (!String.IsNullOrEmpty(pesquisa))
{
usuario = usuario.Where(p => p.nomecompleto.Contains(pesquisa));
}
return View(usuario);
}
This my code above returns the registered users of the site according to the name. I would like the site administrator to have the option to search users both by name and by the CPF (which was set to int
) simply by typing the name or CPF.
Could someone explain if this is possible? And if possible, I'd like to take advantage of the above code.