title: Where clause with Linq in C# MVC 4
body: <p>I'm trying to select a field that is from my UserProfile table, RoleID. The parameter passed into this Post method is Username and it is a string from a textbox which is working correctly.</p>
  
  <pre><code>    [HttpPost]
      [ValidateAntiForgeryToken]
      public ActionResult GetRoles(string UserName)
      {
          if (!string.IsNullOrWhiteSpace(UserName))
          {
               string applyfor = db.Profiles
                 .Select(s =&gt; s.RoleID)
                 .Where(a=&gt;Profile.UserName.Contains(UserName))
                 .First();
               ViewBag.ApplyingFor = applyfor;
  </code></pre>
  
  <p>However this gives me Sequence contains no elements.</p>
  
  <p>I've tried several other methods, such as <code>.Equals()</code>. I'm pretty sure it is my where clause.</p>
  
  <p>What am I doing wrong here?</p>
  
  <p>Note: <code>RoleID</code> is not part of the <code>Websecurity</code>, also there is data in the database.</p>