title: How to make a query string with entity framework
body: <p>I have a complex query which can grow or get smaller depending on which paramaters it receives. Example:</p>
  
  <pre><code>public string CreateQuery(string[]  fields)
  {
      var query = "SELECT student_name,student_last_name FROM students";
  
      if(fields[0]!= "")
      {
          query += " WHERE studient_id='"+fields[0]+"'";
      }
  
      if(fields[1] != null)
      {
          //them....
      }
      //and so on
  
      return query;
  }
  </code></pre>
  
  <p>So i need to execute that query like webmatrix </p>
  
  <pre><code>ViewBag.StudentInf = db.Query("Query string here...");
  </code></pre>
  
  <p>How, then, can I execute a query string with entity Framework??</p>