My solution layout follows this:
- Data - EF entities and DB Context
- Services - Service objects that interact with the database (references the Data project directly)
- Web - Front end (controllers and views) that use the Services project to push/pull data and reflect it back to the user
I recently discovered the ExpressionBuilder to handle grid filtering and convert it to LINQ to use in my Service objects to (efficiently) query the database (pushes the filter down to the DB query) so only a limited number of records are returned (thus, loaded into memory) instead of loading all records and then filtering them in memory.
My question, is there a similar object for Sorting functionality? So it can convert my Grid Sort (from the DataSourceRequest object) into a LINQ OrderBy expression and apply it against my entity type so it can be passed into the DB query? Or am I stuck writing my own?