Dynamic LINQ queries for a web API
<pre><code>public JsonResult GetThis(string typ1)
{     
    ThisContext tpc = new ThisContext();
    IQueryable&lt;ThisDB&gt; oDataQuery = tpc.ThisDBs;
    if (typ1 != null)
    {
        oDataQuery = oDataQuery.Where(a =&gt; a.Type == typ1);
        var result = oDataQuery.ToList();
        return Json(result, JsonRequestBehavior.AllowGet);
    }
    else return null;
}
</code></pre>

<p>The idea here is to create a basic get method that select every rows with the 'good' Type, it's nothing less than a web API method. </p>

<p>The problem is that I don't see why my code is not working, it actually returns nothing ( the database is not empty and if I query it without parameter it's working smoothly ). </p>

<p>This must be a stupid mistake but I can't see it. I know that there is multiple ways to do a dynamic linq query but I'd like first to understand why this is not working. </p>

<p>Thank you for your time ! </p>