title: Comparing byte[] in LINQ-to-SQL and in a unit test that uses mocking
body: <p>I have the following method:</p>
  
  <pre><code>User IDataContext.AuthenticateUser(string userName, string password)
  {
     byte[] hash = PasswordHasher.HashPassword(userName, password);
  
     var query =
         from e in mContext.GetTable&lt;User&gt;()
         where e.Email == userName &amp;&amp; e.Password == hash
         select e;
  
     return query.FirstOrDefault();
  }
  </code></pre>
  
  <p>When <code>mContext</code> is a <code>System.Data.Linq.DataContext</code> everything works great. However, when <code>mContext</code> is an in-memory mock during my uniting testing, the comparison between <code>e.Password</code> and <code>hash</code> always returns <code>false</code>.</p>
  
  <p>If I rewrite this comparison as <code>e.Password.SequenceEqual(hash)</code>, then my unit tests will pass, but I get an exception when I'm talking to LinqToSql. (System.NotSupportedException: The query operator 'SequenceEqual' is not supported.)</p>
  
  <p>Is there a way that I can write this query that will satisfy my unit tests with an in-memory mock, as well as the production component with LinqToSql? </p>