title: Select Max Value in linq to entities
body: <p>I am trying to select MAX LevelId value for a <strong>user</strong> and then assign that value to a variable.</p>
  
  <p>In plain SQL the equivalent is:</p>
  
  <pre><code>SELECT        MAX(LevelID) AS MaxLevel
  FROM            Character
  WHERE        (UserId = 'John')
  
  
  //Check User existing Characters max level per user
  </code></pre>
  
  <p><strong>int UserLevelID = 0;</strong></p>
  
  <pre><code>var userQuery = (from o in db.Characters
  where o.UserId == UserID
        select o);
  </code></pre>
  
  <p><strong>UserLevelID = userQuery.Max(LevelID);</strong></p>
  
  <p>Here lies the problem. I don't know how to extract the max value of levelID</p>