Skip to content

Instantly share code, notes, and snippets.

@jpolvora

jpolvora/JsonQuery.cs

Last active Dec 10, 2015
Embed
What would you like to do?
public ActionResult JsonQuery<T>(IEnumerable<T> resultado, Func<IEnumerable<T>, PartialViewResult> partialView)
{
if (resultado.Any()) return partialView(resultado); //instancia a PartialViewResult
return Json(string.Empty, JsonRequestBehavior.AllowGet);
}
//uso:
return JsonQuery(resultado, x => PartialView("ResultadosDaPesquisa", x));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment