I have a method that gets a object
that can be both int
and string
, does anyone know a way to entity framework
interpret the object!?
I know I can make a if
and do the check, but I'm trying to do it in a simpler way because I'll use it in several places of the code.
Here is an example code:
public JsonResult LoadForm(object id)
{
if ((form = db.tbSystFormulario.FirstOrDefault(f => f.pk_id.CompareTo(id) == 0)) == null)
{
form = db.tbSystFormularioCampo.FirstOrDefault(f => f.tx_nome.CompareTo(id) == 0);
}
return Json(LoadForm(form), JsonRequestBehavior.AllowGet);
}