title: C# web API linq to SQL List object
body: <p>I'm trying create a web API for an autocomplete textbox. I have the API working with sample data, but I don't know how to add data from my table.</p>
  
  <p>Here is my controller:</p>
  
  <pre><code>namespace IMDSEbs.Controllers
  {
      public class CompanyController : ApiController
      {
          // GET: api/Company/GetCompanyNames
          IMDSDataContext dc = new IMDSDataContext();
          public List&lt;CompanyName&gt; results = new List&lt;CompanyName&gt;
          {
              new CompanyName{ID = 1, Name = "Sonu Nigam"},
  
          };
  
          // GET api/values
          public IEnumerable&lt;CompanyName&gt; GetCompanyNames(string query)
          {
              return results.Where(m =&gt; m.Name.Contains(query)).ToList();
          }
      }
  }
  </code></pre>
  
  <p>Here is the table structure (Name is actually the company name):</p>
  
  <pre><code>ID              Name
  ------------------------------------
  1               Abc Company
  2               cde Company
  3               fgh Company
  4               ijk Company
  </code></pre>