title: LINQ Varbinary to C# Byte Array
body: <p>I am new to the whole LINQ system, i have my passwords hashed and stored in a varbinary field in my database, now i want to get that value from my database and store it in a byte array to do a comparison using LINQ.  I did it like this before:</p>
  
  <pre><code>System.Data.SqlTypes.SqlBytes sqlPassBinary = dr.GetSqlBytes(dr.GetOrdinal("Password"));
  </code></pre>
  
  <p>Now i want to try and apply this same concept but using LINQ this time.  I tried this but it didn't work:</p>
  
  <pre><code>public bool Authenticate(string user, string pass)
  {
      ***LINQDataContext d = new ***LINQDataContext();
  
      var login = from us in d.Users
                  join ur in d.UserRoles on us.UserRoleID equals ur.UserRoleID
                  where us.Username == user 
                  select us;
  
      if ((login as IEnumerable&lt;object&gt;).Any())
      {
          System.Web.HttpContext.Current.Session["UserID"] = login.FirstOrDefault().UserID.ToString();
          System.Web.HttpContext.Current.Session["UserRole"] = login.FirstOrDefault().UserRole.ToString();
          byte[] sqlbinary = (byte[]) login.FirstOrDefault().Password;;
  
          return true;
      }
  
      return false;
  }
  </code></pre>
  
  <p>And i get this error:
  <img src="https://i.stack.imgur.com/H44tw.png" alt="enter image description here"></p>