title: Creating new columns in a Select Linq Query based on logical tests
body: <p>I want to convert this 100% working SQL Query into a Linq Query using Vb.net. Thanks</p>
  
  <pre><code>SELECT     
      TOP (100) PERCENT Level3.L2_ID, 
      DATEDIFF(day, Level3.ACT_DATE, BaseLine.ACT_DATE) AS Diff, 
      CASE WHEN datediff(day, Level3.ACT_Date, Baseline.ACT_Date) &gt;0 THEN 1 END AS Green 
  FROM Level3 
  INNER JOIN BaseLine 
      ON Level3.L3_ID = BaseLine.L3_ID
  </code></pre>
  
  <p>I first tried the following code in LinqPad (as a vb Expression) and it is working</p>
  
  <pre><code>From l In Level3s
  Join a In Baselines 
      On l.L3_ID Equals a.L3_ID
  Select 
      Activity = (l.L2_ID) , 
      Diff = (a.ACT_DATE.day-l.Act_Date.day)
  </code></pre>
  
  <p>but does not work when I add</p>
  
  <pre><code>Green = if (a.ACT_DATE.day-l.Act_Date.day) &gt;= 0, 1 end if
  </code></pre>
  
  <p>What is the correct syntax for this.</p>
  
  <pre><code>From l In Level3s
  Join a In Baselines 
       On l.L3_ID Equals a.L3_ID
  Select 
       Activity = (l.L2_ID) , 
       Diff = (a.ACT_DATE.day-l.Act_Date.day),
       Green = if (a.ACT_DATE.day-l.Act_Date.day) &gt;= 0, 1 end if
  </code></pre>