title: The best way to build Dynamic LINQ query
body: <p>Hi I am looking for best method for writing Dynamic LINQ query.</p>
  
  <p>I have a function like</p>
  
  <pre><code>public IQueryable&lt;Student&gt; FindByAllStudents(int? id, string Name, int? CourseID, bool? IsActive) // like this way, all field values are passed
      {    
          // code for compairision
          return db.Student;
      }
  </code></pre>
  
  <p>we can also write db.Students.where(predicate)</p>
  
  <p>or</p>
  
  <p>a query like </p>
  
  <pre><code>var students = from s in db.students where s.Name.Contains(Name)
                  s.ID.Equals(id)
                  //and so on....
  </code></pre>
  
  <p>So will this method works if i don't pass ID (i.e. Null)?
  is proper way for all the datatypes? </p>
  
  <p>The point is function can have all null values as a parameter for equivalence of select * from statement.</p>
  
  <p>can any one help me to build best query with sample code? </p>