neuecc / LINQ-to-BigQuery

LINQ to BigQuery is C# LINQ Provider for Google BigQuery. It also enables Desktop GUI Client with LINQPad and plug-in driver.
MIT License
85 stars 16 forks source link

Groupby Count #44

Open naveensrinivasan opened 8 years ago

naveensrinivasan commented 8 years ago

How do I get this using the library? Which is use the count in the select and order by the count

SELECT actor_login, count(*) as Count FROM [github.dotnet]
WHERE type = "PullRequestEvent"
group by actor_login
order by Count desc
limit 100

I tried this but the

var pr = "PullRequestEvent";
var basequery = From<dotnet>().Where(d => d.type == pr)
.Select(e => new { e.actor_login, e.repo_name })
.GroupBy(e => new { e.actor_login, e.repo_name})
.Limit(100)
.RunDry()
.Dump();

The query it output from the linq is

SELECT
  [actor_login],
  [repo_name]
FROM
  [github-data-1163:github.dotnet]
WHERE
  ([type] = 'PullRequestEvent')
GROUP BY
  [actor_login],
  [repo_name]
LIMIT 100
neuecc commented 8 years ago

All BigQuery's function under BqFunc. You can write .Select(e => new { count = BqFunc.Count(), e.actor_login, e.repo_name }) or .Select(e => new { count = Count(), e.actor_login, e.repo_name })

naveensrinivasan commented 8 years ago

Thanks for the support. Could I do a PR for the README with all the things I learn trying to use this?