My view's model is an IEnumerable<SomeModel> so in my controller I do this:
[HttpGet]
public PartialViewResult show() {
    IQueryable query= from data in entity.dbCtxt
        select data;
    return PartialView("show", query.ToList());
}
Turns out IQueryable does not contain the definition of ToList()...
public interface IQueryable : IEnumerable{
     Type ElementType { get; }
     Expression Expression { get; }
     IQueryProvider Provider { get; }
}
How do I cast IQueryable into a list?
Because ToList is an extension method of IQueryable<T>, not IQueryable. if that is your query, you can simply do this:
public PartialViewResult show() {
        return PartialView("show", dbCtxt.YourDbSet.ToList());
}
DbSet<T> class inherits from IQueryable<T>, so if you idea is to fetch all the rows of that table, you can call ToList directly from your DbSet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With