title: Cannot get data using LINQ in MVC
body: <p>I'm trying to get data in autocomplete from JsonResult Action Method in my controller. I cannot query data with LINQ, I'm sharing code please guide me.</p>
  
  <p>Action Method</p>
  
  <pre><code>public class VehicleController : Controller
  {
          private readonly IService&lt;Vehicle&gt; _service;
  
          public VehicleController(IService&lt;Vehicle&gt; service)
          {
              _service = service;
          }
      public JsonResult AutoComplete(string term)
      {
         var vehicle = _service.GetAll().Select(c =&gt; new { Name = c.Name });
         return Json(vehicle, JsonRequestBehavior.AllowGet);
      }
  }
  </code></pre>
  
  <p>EntityRepository</p>
  
  <pre><code>public class EntityRepository&lt;TEntity&gt; : IRepository&lt;TEntity&gt; where TEntity : BaseEntity
  {
      private readonly IEntitiesContext _context;
      private readonly IDbSet&lt;TEntity&gt; _dbEntitySet;
      private bool _disposed;
  
      public EntityRepository(IEntitiesContext context)
      {
         _context = context;
         _dbEntitySet = _context.Set&lt;TEntity&gt;();
      }
  
      public List&lt;TEntity&gt; GetAll()
      {
         return _dbEntitySet.ToList();
      }
  }
  </code></pre>
  
  <p>IRepository</p>
  
  <pre><code>public interface IRepository&lt;TEntity&gt; : IDisposable where TEntity : BaseEntity
  {
     List&lt;TEntity&gt; GetAll();
  }
  </code></pre>
  
  <p>Service</p>
  
  <pre><code>public class Service&lt;TEntity&gt; : IService&lt;TEntity&gt; where TEntity : BaseEntity
  {
     public IUnitOfWork UnitOfWork { get; private set; }
     private readonly IRepository&lt;TEntity&gt; _repository;
     private bool _disposed;
  
     public Service(IUnitOfWork unitOfWork)
     {
        UnitOfWork = unitOfWork;
        _repository = UnitOfWork.Repository&lt;TEntity&gt;();
     }
  
     public List&lt;TEntity&gt; GetAll()
     {
        return _repository.GetAll();
     }
  }
  </code></pre>
  
  <p>IService</p>
  
  <pre><code>public interface IService&lt;TEntity&gt; : IService where TEntity : BaseEntity
  {
      List&lt;TEntity&gt; GetAll();
  }
  </code></pre>
  
  <p>Action Method is returning a complete list of data but when I apply any filter it won't work and returns no values -- e.g I tried this and it returns null:</p>
  
  <pre><code>var vehicle = _service.GetAll().Where(c =&gt; c.Name.StartsWith(term)).Select(c =&gt; new { Name = c.Name });
  </code></pre>