title: Creating a Search bar c# MVC
body: <p>I am trying to create a search bar within my MVC application. I have the following model</p>
  
  <pre><code>    public class Project
  {
      public int projectID { get; set; }
      public int customerID { get; set; }
      public int departmentID { get; set; }
      public string projectName { get; set; }
      public int employeeID { get; set; }
  }
  </code></pre>
  
  <p>I want to create a search bar within my index view allowing users to search the list of projects by entering either the projectID or the projectName. So far I have it searching on projectName but I am unsure how (or if it's possible) to search by ID or both at the same time. 
  This is the search bar in my Index view :</p>
  
  <pre><code>   @using (Html.BeginForm())
  {
  &lt;p&gt;
      Name  : @Html.TextBox("SearchName")&lt;br /&gt;
      &lt;input type="submit" value="Search" /&gt;
  &lt;/p&gt;
  }
  </code></pre>
  
  <p>This is my controller method </p>
  
  <pre><code>    public ActionResult Index(string searchName)
      {
  
          var projects = from pr in db.projects select pr;
  
          if (!String.IsNullOrEmpty(searchName))
          { 
              projects = projects.Where(c =&gt;  c.projectName.Contains(searchName));
        }
  
          return View(projects);
        }
  </code></pre>
  
  <p>Any advice or help would be greatly appreciated! Thanks</p>