You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2017/07/17 05:55:01 UTC
[jira] [Comment Edited] (GROOVY-8258) Create a LINQ-like DSL
[ https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16089344#comment-16089344 ]
Paul King edited comment on GROOVY-8258 at 7/17/17 5:54 AM:
------------------------------------------------------------
LINQ works across collections, XML documents (when parsing) and relational databases using a stream-like API underneath. I'd be keen for us to work on stream-based versions of SQL, XML and collection processing capabilities and then think about the DSL sugar on top of that at a later stage. If it was indeed a syntactic sugar layer on top of a well thought out API (as in C#) then I think it would belong in the language.
was (Author: paulk):
LINQ works across collections, XML documents (when parsing) and relational databases using a stream-like API underneath. I'd be keen for us to work on stream-based versions of SQL, XML and collection processing capabilities and then think about the DSL sugar on top of that at a later stage.
> Create a LINQ-like DSL
> ----------------------
>
> Key: GROOVY-8258
> URL: https://issues.apache.org/jira/browse/GROOVY-8258
> Project: Groovy
> Issue Type: Improvement
> Reporter: Daniel Sun
>
> *Pojos:*
> {code:java}
> class Category {
> String name
> List<Article> articles
> }
> class Article {
> String name
> Integer voteCount
> String categoryName
> }
> {code}
> *Example1:*
> {code:java}
> linq { // return an Iterator<Map<String, Object>>
> from c of categories
> join a of articles on a.categoryName == c.name // join
> where c.name == 'Groovy'
> orderBy a.voteCount desc // order by
> limit 100 offset 50 // pagination
> select { // create a map, its keys: articleName, voteNum, categoryName
> articleName = a.name
> a.voteCount
> categoryName = c.name
> }
> }
> {code}
> *Example2:*
> {code:java}
> linq { // return an Iterator<Map<String, Object>>
> from c of categories
> join a of {
> from tempA of articles
> where tempA.voteCount > 10
> select tempA
> } on a.categoryName == c.name // join
> where c.name == 'Groovy'
> orderBy a.voteCount desc // order by
> limit 100 offset 50 // pagination
> select { // create a map, its keys: articleName, voteNum, categoryName
> articleName = a.name
> a.voteCount
> categoryName = c.name
> }
> }
> {code}
> *Example3:*
> {code:java}
> linq { // return an Iterator<Article>
> from c of categories
> from a of c.articles // another join
> where c.name == 'Groovy'
> orderBy a.voteCount desc // order by
> select Article { // create an Article instance
> a.name
> a.voteCount
> categoryName = c.name
> }
> }
> {code}
> *TO BE CONTINUED...*
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)