-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Conditional where's, orderBy's, and thenBy's #59
Comments
Have you been using these as extensions methods in your own project yet? |
When using both where and whereIf in the same query, they're composed with AND. I added these two tests locally and they both passed:
|
The reason I am hesitant to add these methods to the builder is that I would like to avoid an explosion of subtle variations of First we add So I think that it would be better to create one extra select {
for c in main.Customer do
where (filters.LastName.IsSome) (Where.And) (c.LastName = filters.LastName.Value)
where (filters.FirstName.IsSome) (Where.And) (c.FirstName = filters.FirstName.Value) Which admittedly is kind of ugly. |
Here is another possible variation of the conditional where clause that looks pretty clean: select {
for c in main.Customer do
where (
(filters.LastName.IsSome && c.LastName = filters.LastName.Value) &&
(filters.FirstName.IsSome && c.FirstName = filters.FirstName.Value)
)
} |
My apologies for dragging my feet on this for so long. While I'm mulling this design idea around, I am adding a new feature in the meantime that provides direct access to the underlying This will make it pretty easy to add conditional where and order by clauses, as well as many other query customizations. https://github.com/JordanMarr/SqlHydra/releases/tag/query-v2.0.2 |
No reason to apologize- I've been the one that's been too busy to respond. Do whatever you feel is best! Thanks for the continuous work you put into it. |
I just saw this post by @SchlenkR about adding conditional fields: Which would provide the ideal syntax for conditional where statements: select {
for c in main.Customer do
if filters.FirstName.IsSome then
where (c.FirstName = filters.FirstName.Value)
if filters.LastName.IsSome then
where (c.LastName = filters.LastName.Value)
} I may take a stab at trying to implement this based off his code: |
I saw this issue a while ago and thought I'd contribute.
If you'd like a PR instead, I'd be happy to send one over.
The text was updated successfully, but these errors were encountered: