Windows phone 7 如何在windows phone中从本地数据库获取最大值?

Windows phone 7 如何在windows phone中从本地数据库获取最大值?,windows-phone-7,sql-server-ce,iqueryable,isolatedstorage,Windows Phone 7,Sql Server Ce,Iqueryable,Isolatedstorage,我需要从属于特定类别的表中获取最大值。 我的代码如下: private int getHighScores(int _playMode) { int maxScore = 0; using (HangmanScoreDataContext hangmanDB = new HangmanScoreDataContext(@"isostore:/HangmanScoreDB.sdf")) { IQueryable<

我需要从属于特定类别的表中获取最大值。 我的代码如下:

 private int getHighScores(int _playMode)
    {
        int maxScore = 0;
        using (HangmanScoreDataContext hangmanDB = new HangmanScoreDataContext(@"isostore:/HangmanScoreDB.sdf"))
        {
            IQueryable<TbleHangmanScore> sqlQuery = hangmanDB._tbleHangman;
            sqlQuery = sqlQuery.Where(p => p.playMode == _playMode);                 
            maxScore = sqlQuery.AsQueryable().Max(p => p.score);

        }
        return maxScore;
    }
private int getHighScores(int\u播放模式)
{
int maxScore=0;
使用(HangmanScoreDataContext hangmanDB=new HangmanScoreDataContext(@“isostore:/HangmanScoreDB.sdf”))
{
IQueryable sqlQuery=hangmanDB.\u tbleHangman;
sqlQuery=sqlQuery.Where(p=>p.playMode===\u playMode);
maxScore=sqlQuery.AsQueryable().Max(p=>p.score);
}
返回maxScore;
}
我犯了这样的错误

未知模块中发生“system.stackoverflowexception”类型的未处理异常。 除了最大值之外,其余的东西工作正常。我如何解决这个问题

编辑:只有当表包含零条记录时,问题才会出现。同样的问题,当我试图得到最小值也