I want to create a bindingSource that supports sorting by multiple columns and attach it to a bindingNavigator. I am using winforms and code-first EF.
I am constructing my query in the following manner
DbSet<Person> dset = DBContext.People;
string Searchstr ="Smith";
string sortby ="LastName, FirstName"
var qry = (IOrderedQueryable<Person>) dset.Where(
p => p.LastName.Contains(Searchstr) )
.OrderBy(sortby);
binding.datasource = dset.Local.ToBindingList(); // where binding has been dropped on form at design time.
binding.sort = sortby; // this is the line that screws up the sort order
I am using the extension method documented here to achieve the multi-column order by.