title: LINQ: Set a default value if navigation property is null
body: <p>This is my current LINQ statement:</p>
  
  <pre><code>var results = from l in leads
      select new MyObject
      {
          LeadID = l.LeadID,
          SelectedProposalEngineerID = l.LeadContacts.Where(contact =&gt; contact.LeadContactTypeID == LeadContactType.ProposalEngineer).FirstOrDefault().ContactID
      };
  </code></pre>
  
  <p>The trouble I'm having is that the last item is often null.  So when I try to convert "results" to a List, I get</p>
  
  <blockquote>
    <p>{"The cast to value type 'System.Int32' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type."}</p>
  </blockquote>
  
  <p>I don't want to make SelectedProposalEngineerID  a nullable int, for problems that would cause down stream.  How would I give it a value of 0 when it's null?</p>
  
  <p>I have seen a LOT of other threads about this, but I can't seem to adapt any of their answers to this case.</p>