I am using the following query in vb.net using the System.Linq.Dynamic library to bind the result to a gridview
Dim customers = model.Customers _
.OrderBy(sortExp + " " + sortOrder) _
.Select("new (CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax)")
grdCustomers.DataSource = customers
grdCustomers.DataBind()
The following error is displayed
Data binding directly to a store query (DbSet, DbQuery, DbSqlQuery) is not supported. Instead populate a DbSet with data, for example by calling Load on the DbSet, and then bind to local data. For WPF bind to DbSet.Local. For WinForms bind to DbSet.Local.ToBindingList().
The result returned is of type DbQuery but I cannot do a ToList() on the result.
There must be a cleaner way to create a list instead of interating through the customers and creating the list manually.