I'm trying to create a generic GetAll method that works for each of my model classes in my ASP.NET MVC4 project.
Here's my code:
public static List<T> GetAll(params string[] includeProperties)
{
using (MovieSiteDb db = new MovieSiteDb())
{
var entities = db.Set<T>();
foreach (var includeProperty in includeProperties)
{
entities.Include(includeProperty);
}
return entities.ToList();
}
}
Now I call it the following way (Movie inherits the GetAll method):
Movie.GetAll("Category");
However I get an error when I try to access the foreign key "Category" in the view model. Why isn't it being included?