title: Linq to SQL: .FirstOrDefault() not applicable to select new { ... }
body: <p>I just asked <a href="https://stackoverflow.com/questions/201686/linq-to-sql-select-optimization">this question</a>. Which lead me to a new question :)</p>
  
  <p>Up until this point, I have used the following pattern of selecting stuff with Linq to SQL, with the purpose of being able to handle 0 "rows" returned by the query:</p>
  
  <pre><code>var person = (from p in [DataContextObject].Persons
                where p.PersonsID == 1
                select new p).FirstOrDefault();
  
  if (person == null)
  {
      // handle 0 "rows" returned.
  }
  </code></pre>
  
  <p>But I can't use <code>FirstOrDefault()</code> when I do:</p>
  
  <pre><code>var person = from p in [DataContextObject].Persons
               where p.PersonsID == 1
               select new { p.PersonsID, p.PersonsAdress, p.PersonsZipcode };
  
  // Under the hood, this pattern generates a query which selects specific
  // columns which will be faster than selecting all columns as the above
  // snippet of code does. This results in a performance-boost on large tables.
  </code></pre>
  
  <p>How do I check for 0 "rows" returned by the query, using the second pattern?
  <br />
  <br />
  <br />
  <br />
  <strong>UPDATE:</strong></p>
  
  <p>I think my build fails because I am trying to assign the result of the query to a variable (<code>this._user</code>) declared with the type of <code>[DataContext].User</code>.</p>
  
  <pre><code>this._user = (from u in [DataContextObject].Users
                where u.UsersID == [Int32]
                select new { u.UsersID }).FirstOrDefault();
  </code></pre>
  
  <p><em>Compilation error: Cannot implicitly convert type "AnonymousType#1" to "[DataContext].User".</em></p>
  
  <p>Any thoughts on how I can get around this? Would I have to make my own object?</p>