0
I am having this error when trying to make one with query using LINQ to SQL after making the suggested changes:
{SELECT
`Extent1`.`idcliente`,
`Extent1`.`nome`,
`Extent1`.`pai`,
`Extent1`.`mae`,
`Extent1`.`informacao`,
`Extent1`.`datanascimento`,
`Extent1`.`foto`
FROM `cliente` AS `Extent1`
WHERE (LOCATE(TRIM(@p__linq__0), `Extent1`.`mae`)) = 1}
C#
[HttpPost]
public ActionResult Index(string recebeNome, int recebeOpcao)
{
try
{
sistema_mobileEntities dao = new sistema_mobileEntities();
IQueryable<cliente> sql;
sql = null;
if (recebeOpcao == 1)
{
//link to sql não tem like
sql = from c in dao.cliente
where c.nome.StartsWith(recebeNome.Trim())
// where SqlMethods.Like(c.nome, recebeNome.Trim() + "%")
select c;
TempData["opcao1"] = "nome";
}
if (recebeOpcao == 2)
{
sql = from c in dao.cliente
where c.pai.StartsWith(recebeNome.Trim())
select c;
TempData["opcao2"] = "pai";
}
if (recebeOpcao == 3)
{
sql = from c in dao.cliente
where c.mae.StartsWith(recebeNome.Trim())
select c;
TempData["opcao3"] = "mae";
}
return View(sql.ToList());
}
catch (Exception ex)
{
return Json("Erro ao consultar cliente" + ex.Message);
}
}
Did any help you more? You need something to be improved?
– Maniero