title: How to get the maximum value from local database in windows phone?
body: <p>I need to get the maximum value from table that should belongs to particular category.
  My code as follows : </p>
  
  <pre><code> private int getHighScores(int _playMode)
      {
          int maxScore = 0;
          using (HangmanScoreDataContext hangmanDB = new HangmanScoreDataContext(@"isostore:/HangmanScoreDB.sdf"))
          {
              IQueryable&lt;TbleHangmanScore&gt; sqlQuery = hangmanDB._tbleHangman;
              sqlQuery = sqlQuery.Where(p =&gt; p.playMode == _playMode);                 
              maxScore = sqlQuery.AsQueryable().Max(p =&gt; p.score);
  
          }
          return maxScore;
      }
  </code></pre>
  
  <p>I am getting error like </p>
  
  <blockquote>
    <p>an unhandled exception of type 'system.stackoverflowexception' occurred in unknown module.
    Except maximum  value rest of the things working properly . How can i solve this issue ?</p>
  </blockquote>
  
  <p>Edit : Problem arises only when the table contains zero numbers of records. Same problem when i trying to get the minimum value also.</p>