[jira] [Commented] (GROOVY-8258) Create a LINQ-like DSL

2017-08-22 Thread Daniel Sun (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16137635#comment-16137635
 ] 

Daniel Sun commented on GROOVY-8258:


Hi Markus, creating something like LINQ is really a big task, thanks for your 
sharing your experience :-)

> 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 articles
> }
> class Article {
>   String name
>   Integer voteCount
>   String categoryName
> }
> {code}
> *Example1:*
> {code:java}
> linq { // return an Iterator>
> 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>
> 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
> 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)


[jira] [Commented] (GROOVY-8258) Create a LINQ-like DSL

2017-08-22 Thread mg (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16137421#comment-16137421
 ] 

mg commented on GROOVY-8258:


Hi Daniel, back when I did .NET development, creating a LINQ provider used to 
be a non-trivial task, so if you have not seen this, maybe it might be 
interesting to have a look at their approach:
# https://relinq.codeplex.com/
# 
https://www.codeproject.com/Articles/42059/re-linq-ishing-the-Pain-Using-re-linq-to-Implement



> 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 articles
> }
> class Article {
>   String name
>   Integer voteCount
>   String categoryName
> }
> {code}
> *Example1:*
> {code:java}
> linq { // return an Iterator>
> 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>
> 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
> 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)


[jira] [Commented] (GROOVY-8258) Create a LINQ-like DSL

2017-07-17 Thread Daniel Sun (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16091057#comment-16091057
 ] 

Daniel Sun commented on GROOVY-8258:


OK. I'll create a branch linq-dsl(based on master) and subproject linq-dsl at 
the weekend :)

> 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 articles
> }
> class Article {
>   String name
>   Integer voteCount
>   String categoryName
> }
> {code}
> *Example1:*
> {code:java}
> linq { // return an Iterator>
> 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>
> 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
> 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)


[jira] [Commented] (GROOVY-8258) Create a LINQ-like DSL

2017-07-17 Thread Paul King (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16090894#comment-16090894
 ] 

Paul King commented on GROOVY-8258:
---

Sure, I thought that was what you were implying, I was just clarifying.

> 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 articles
> }
> class Article {
>   String name
>   Integer voteCount
>   String categoryName
> }
> {code}
> *Example1:*
> {code:java}
> linq { // return an Iterator>
> 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>
> 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
> 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)


[jira] [Commented] (GROOVY-8258) Create a LINQ-like DSL

2017-07-17 Thread Daniel Sun (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16090835#comment-16090835
 ] 

Daniel Sun commented on GROOVY-8258:


> But in terms of merging into the main branches, we could merge a PR that was 
> improving the underlying APIs to make them stream-aware (without any DSL)
Agreed.

Paul, maybe I did not express the proposal clearly. The DSL should consist of 
not only syntactic sugar layer but also the backend, so it will be a big work ;)
We can design DSL and implement the underlying APIs at first and then implement 
the DSL, in other words, the API design is driven by the DSL. e.g. In the 
following sample code, we can find we need linq, from, of, join, on, where, 
orderBy, limit, offset, select methods, which will appear in our underlying 
APIs.

{code:java}
linq { // return an Iterator>
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}


> 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 articles
> }
> class Article {
>   String name
>   Integer voteCount
>   String categoryName
> }
> {code}
> *Example1:*
> {code:java}
> linq { // return an Iterator>
> 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>
> 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
> 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)


[jira] [Commented] (GROOVY-8258) Create a LINQ-like DSL

2017-07-17 Thread Paul King (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16090736#comment-16090736
 ] 

Paul King commented on GROOVY-8258:
---

Sure, there is no problem with thinking about things from different approaches! 
In fact, it's useful to go both directions sometimes. :-)

But in terms of merging into the main branches, we could merge a PR that was 
improving the underlying APIs to make them stream-aware (without any DSL), but 
I would most likely be -1 on a PR that was just the DSL without the underlying 
API changes. Doesn't mean we have can't start an incomplete feature branch of 
course to get the ball rolling.

> 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 articles
> }
> class Article {
>   String name
>   Integer voteCount
>   String categoryName
> }
> {code}
> *Example1:*
> {code:java}
> linq { // return an Iterator>
> 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>
> 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
> 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)


[jira] [Commented] (GROOVY-8258) Create a LINQ-like DSL

2017-07-17 Thread Daniel Sun (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16089601#comment-16089601
 ] 

Daniel Sun commented on GROOVY-8258:


Time is a problem, but we can push the progress step by step. I think we can 
create a new sub-project linq-dsl at first ;)

> 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 articles
> }
> class Article {
>   String name
>   Integer voteCount
>   String categoryName
> }
> {code}
> *Example1:*
> {code:java}
> linq { // return an Iterator>
> 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>
> 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
> 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)


[jira] [Commented] (GROOVY-8258) Create a LINQ-like DSL

2017-07-17 Thread Paul King (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16089568#comment-16089568
 ] 

Paul King commented on GROOVY-8258:
---

[~daniel_sun] Yes, that was what I was trying to clarify and to indicate that I 
think we have some more work to do at the stream API level before creating a 
LINQ-like DSL layer. Obviously, you'd want to have the latter in mind when 
designing the former. I don't think our current APIs are exactly what we want 
to layer on top of.

> 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 articles
> }
> class Article {
>   String name
>   Integer voteCount
>   String categoryName
> }
> {code}
> *Example1:*
> {code:java}
> linq { // return an Iterator>
> 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>
> 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
> 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)


[jira] [Commented] (GROOVY-8258) Create a LINQ-like DSL

2017-07-17 Thread Daniel Sun (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16089499#comment-16089499
 ] 

Daniel Sun commented on GROOVY-8258:


LINQ will translate LINQ statement into method calls, which is like stream API 
of Java 8. LINQ-like DSL is just a syntactic sugar, the backend is the stream 
API.

{code:java}
// C# LINQ method calls
IQueryable source = database.Products;
var results = source.Where(product => product.ReorderLevel > 20)
.Select(product => new
{
ProductName = string.Concat("@", 
product.ProductName),
UnitPrice = product.UnitPrice
});
{code}


> 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 articles
> }
> class Article {
>   String name
>   Integer voteCount
>   String categoryName
> }
> {code}
> *Example1:*
> {code:java}
> linq { // return an Iterator>
> 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>
> 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
> 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)


[jira] [Commented] (GROOVY-8258) Create a LINQ-like DSL

2017-07-16 Thread Paul King (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16089344#comment-16089344
 ] 

Paul King commented on GROOVY-8258:
---

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 articles
> }
> class Article {
>   String name
>   Integer voteCount
>   String categoryName
> }
> {code}
> *Example1:*
> {code:java}
> linq { // return an Iterator>
> 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>
> 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
> 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)


[jira] [Commented] (GROOVY-8258) Create a LINQ-like DSL

2017-07-16 Thread Daniel Sun (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16089308#comment-16089308
 ] 

Daniel Sun commented on GROOVY-8258:


LINQ is a part of C#, so I think LINQ-like DSL should also be a part of Groovy 
:D

> 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 articles
> }
> class Article {
>   String name
>   Integer voteCount
>   String categoryName
> }
> {code}
> *Example1:*
> {code:java}
> linq { // return an Iterator>
> 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>
> 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
> 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)


[jira] [Commented] (GROOVY-8258) Create a LINQ-like DSL

2017-07-16 Thread John Wagenleitner (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16089058#comment-16089058
 ] 

John Wagenleitner commented on GROOVY-8258:
---

The DSL looks like it could be useful in certain situations.  But my opinion is 
that something like this would be best provided as an external library and not 
included (from the start anyway) as part of Groovy itself or one of its 
subprojects.

> 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 articles
> }
> class Article {
>   String name
>   Integer voteCount
>   String categoryName
> }
> {code}
> *Example1:*
> {code:java}
> linq { // return an Iterator>
> 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>
> 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
> 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)