You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (JIRA)" <ji...@apache.org> on 2017/07/16 17:24:01 UTC
[jira] [Updated] (GROOVY-8258) Create a LINQ-like DSL
[ https://issues.apache.org/jira/browse/GROOVY-8258?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Sun updated GROOVY-8258:
-------------------------------
Description:
*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
from a of c.articles // join
where c.name == 'Groovy'
orderBy a.voteCount desc // order by
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<Article>
from c of categories
from a of c.articles // 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...*
was:
*Example1:*
{code:java}
linq { // return an Iterator<Map<String, Object>>
from c of categories
from a of c.articles // join
where c.name == 'Groovy'
orderBy a.voteNum desc // order by
select { // create a map, its keys: articleName, voteNum, categoryName
articleName = a.name
a.voteNum
categoryName = c.name
}
}
{code}
*Example2:*
{code:java}
linq { // return an Iterator<Article>
from c of categories
from a of c.articles // join
where c.name == 'Groovy'
orderBy a.voteNum desc // order by
select Article { // create an Article instance
a.name
a.voteNum
categoryName = c.name
}
}
TO BE CONTINUED...
{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<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
> from a of c.articles // join
> where c.name == 'Groovy'
> orderBy a.voteCount desc // order by
> 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<Article>
> from c of categories
> from a of c.articles // 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)