Make query using Object with the Entity Framework

1

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);
}
    
asked by anonymous 15.06.2015 / 04:21

0 answers