I am using Entity Framework with a MySQL database to store a table of hundreds of thousands of packages. When I try to bind directly to the query:
protected
void
OnPackagesNeedDataSource(
object
source, GridNeedDataSourceEventArgs e)
{
PackageGrid.DataSource = PageServerDataContext.Packages;
}
I get the error, "Data binding directly to a store query (DbSet, DbQuery, DbSqlQuery, DbRawSqlQuery) is not supported."
Using .ToList() would mean that I need to load all the packages in the database, which is not practical.
I can use an EntityDataSource, but I would rather set the data programmatically.
How do I use NeedDataSource with EntityFramework without using .ToList()?