I have a question about how to return the records according to the query. I do not know what might be wrong, but the query is not returning according to what was passed.
I have my controller:
public ActionResult Index()
{
//retornar todos os registros
sistema_mobileEntities dao = new sistema_mobileEntities();
TempData["titulo1"] = "Consulta Registro";
return View(dao.cliente.ToList());
}
[HttpPost]
public ActionResult Index(string recebeNome, int recebeOpcao)
{
try
{
sistema_mobileEntities dao = new sistema_mobileEntities();
if (recebeOpcao == 1)
{
var sql = from c in dao.cliente
where SqlMethods.Like(c.nome, recebeNome.Trim() + "%")
select c;
TempData["opcao1"] = "nome";
}
if (recebeOpcao == 2)
{
var sql = from c in dao.cliente
where SqlMethods.Like(c.pai, recebeNome.Trim() + "%")
select c;
TempData["opcao2"] = "pai";
}
if (recebeOpcao == 3)
{
var sql = from c in dao.cliente
where SqlMethods.Like(c.mae, recebeNome.Trim() + "%")
select c;
TempData["opcao3"] = "mae";
}
return View(dao.cliente.ToList());
}
catch (Exception ex)
{
return Json("Erro ao consultar usuario" + ex.Message);
}
}