title: Linq is this string.Compare in the query inefficient and is there a better way?
body: <p>Originally I had this method:</p>
  
  <pre><code>public virtual User GetUser(string username)
          {
              return _db.Users.Single(x =&gt; x.UserName == username);
          }
  </code></pre>
  
  <p>So basically a linq method which gets a user based on the person's username.</p>
  
  <p>Trouble was I found that sometimes the username was coming through with an uppercase character at the start so it wasn't always working.</p>
  
  <p>So then I came up with:</p>
  
  <pre><code>public virtual User GetUser(string username)
          {
              return _db.Users.Single(x =&gt; (string.Compare(x.UserName, username, true) == 0));
          }
  </code></pre>
  
  <p>This works. However I get this must be really inefficient to do a string.Compare for the users?</p>
  
  <p>Is there a better way to write this without the string.Compare?</p>