title: multiple where in linq based on parameters value
body: <p>I want to have multiple where clauses in linq but out of them only one should execute, i was trying something like this:</p>
  
  <pre><code>public JsonResult GetPost(int? id, int? tagid, DateTime? date)
  {
      var ret = from data in db.Posts.Include(x =&gt; x.Tags)
                   .Include(x =&gt; x.Neighbourhood)
                   .Where((x =&gt; x.NeighbourhoodId == id) || (y =&gt; y.PostedDate == date) || third condition).ToList()
  </code></pre>
  
  <p>but i was unable to put second and third condition there becoz after putting dot after y, i cant see any options.</p>
  
  <p>Now, out of these three, only one parameter would have value and other two would have null so, it should checks for parameter only with value.</p>
  
  <p>should i write query like this, is it correct way:</p>
  
  <pre><code>if (id != null)
  {
  //whole query here
  }
  else if (tagid != null)
  {
  //whole query here
  }
  else (date != null)
  {
  //whole query here
  }
  </code></pre>
  
  <p>Is it the best way to do this or something else is possible. many many thnks in advance for any suggestion.</p>