title: LINQ to SQL with null values
body: <p>Can anyone help me figure this out?</p>
  
  <p>The below code works fine and gets inside the if statument</p>
  
  <pre><code>foreach (var m in msg)
  {
      if (string.IsNullOrEmpty(m.PhoneNumber))
      {
          m.PhoneNumber = (from c in db.Customers
                              where c.CustomerID == m.CustomerID
                              select c.PhoneNumber).Single();
      }
  }
  </code></pre>
  
  <p>However in the below code phoneNumber is never set</p>
  
  <pre><code>foreach (var m in msg.Where(z =&gt; (z.PhoneNumber == null || z.PhoneNumber == "")))
  {
       m.PhoneNumber = (from c in db.Customers
                        where c.CustomerID == m.CustomerID
                        select c.PhoneNumber).Single();
  }
  </code></pre>
  
  <p>I'm presuming its because the top code actually evaluates the expression whereas the below dosent. If that is the case then how can you check for null on an unevaluated LINQ query?</p>
  
  <p><strong>EDIT</strong> Just to stop confusion here is how msg is poplated in both cases</p>
  
  <pre><code>    var msg = from m in db.Messages
                where (m.StatusID == (int)MessageStatus.Submitted &amp;&amp; m.MessageBoxTypeID == (int)MessageBoxType.Outbox)
                select m;
  </code></pre>