title: LINQ with if statement
body: <p>My LINQ query returns values if "attribute" is bigger than 0 else it doesn't work and I get no error. 
  I guess the &amp;&amp; in the third line wants another statement which it doesn't get if "attribute" isn't bigger than 0. How can I get over this? </p>
  
  <p>Edit: The code I've written first, was doing what abatishchev's answer is saying. I've tried to do a shorthand if statement without else but I've read about that wrong, so the code was meant to do something else then it actualy did. Thank you for the enlightenment on that matter but I still don't know how to implement my initial wish to linq, so I've rearranged the code to something that is nearer to my goal.</p>
  
  <pre><code>int attribute = 0;
  var query = from x in db.Table1
              where x.ValueId == 1
  
              if(attribute &gt; 0)
                  x.Table2.Attribute == attribute
  
              select x;
  </code></pre>
  
  <p>If attribute is bigger than 0, then I wan't to add an additional where clause to my query.</p>
  
  <p>Thank you for your help.</p>