Skip to content
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

LINQ style queries in Squeal? #280

Open
echatav opened this issue Mar 9, 2021 · 1 comment
Open

LINQ style queries in Squeal? #280

echatav opened this issue Mar 9, 2021 · 1 comment
Labels

Comments

@echatav
Copy link
Contributor

echatav commented Mar 9, 2021

The question recently was asked at work:

Have you considered putting the select at the end instead of the beginning? C#’s LINQ ended up making that change in its approach to a SQL-like DSL. Not sure it would help but I was curious if you considered that approach or not.

I hadn't considered it at all but in fact, with more thorough use of the reverse function application operator (&), Squeal already supports this LINQ style:

-- LINQ style
from (table #scores)
  & where_ (#score .> 80)
  & groupBy #winner
  & select_
    ( #winner :*
      max_ #score `as` #best_score
    )

-- SQL style
select_
  ( #winner :*
    max_ #score `as` #best_score
  )
  ( from (table #scores)
    & where_ (#score .> 80)
    & groupBy #winner
  )
@echatav echatav changed the title LINQ style queries in Squeal LINQ style queries in Squeal? Mar 9, 2021
@gasi
Copy link
Contributor

gasi commented Dec 2, 2023

Brilliant 👏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants