-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typesafe dynamic filtering/ordering/paging #8
Comments
This will be a nice very very addition. For the orderBy, is there any overhead in supporting more than two columns ? E.g This could work nicely with With respect to the paging, one other piece of data that is also generated is the count of the records so the ui can properly show paging data when not using infinite scroll. Eg. |
Excellent point about the total count for paging. I now think there should be a typesafe API for wrapping a static query as a subquery, letting you produce anything of the form:
As long as Every database engine, even SQLite, can push down predicates and limit clauses into subqueries. They basically have to be good at this to support views, because otherwise views would be pretty useless. So I'm not too worried about the performance implications of putting these filters/limits in an outer query. This would only work for queries that do not use navigation properties. With a These dynamic features would be most commonly used when you have a flat result set anyway (that you're displaying to the end user as tabular data), so not letting them be used on nav-property queries seems OK for now. Maybe in the future a subset of operations could be allowed -- no count/limit/offset, and only involving the columns that aren't under nav properties. |
Right now there is no way to dynamically order queries.
This makes the library unsuitable for applications that let the user sort a paged table of records.
That's a lot of applications!
This should be solvable without giving up type safety. Here's the design I have in mind:
Any command that consists of a single
SELECT
statement which is not known to be a single-row SELECT should be dynamically orderable.e.g.
This means that it gets the following extra stuff in its generated type:
MyQuery.By
with a private constructor and an overrided ToString().MyQuery.By.Column1
andMyQuery.By.Column2
, which return instances ofMyQuery.By
MyQuery.By.OfString("Column1")
which checks that the passed string is one of the statically known output column names.MyQuery.By.OfString(MyQuery.By.Column2.ToString())
should work.OrderBy
method taking aMyQuery.By
and a DUAscending|Descending
and returning aMyQuery.OrderedQuery
MyQuery.OrderedQuery
has an instance methodThenBy
taking another by+direction,Page
taking limit+offsetMyQuery.OrderedQuery
has an instanceCommand
method which is like the regularMyQuery.Command(param1 = ...)
method, but includes the orderings applied so farHypothetical usage:
I think it would be OK to limit to one
ThenBy
clause. Orderings more complicated than that don't make much sense to generate dynamically.Thoughts?
The text was updated successfully, but these errors were encountered: