Hello, I know scala have Slick , but it's too ugly than C# LINQ.
Here is the Scala SLICK syntax:
val q = for {
c <- Coffees if c.supID === 101
} yield (c.name, c.price)
This would be equivalent to the following C#:
// LINQ extension method syntax
var q = Coffees.Where(c => c.supID == 101)
.Select(c => new { c.name, c.Price});
// LINQ query syntax
var q = from c in Coffees
where c.supId == 101
select new { c.name, c.price};
Yield and Select appear to be the same sort of projection routine.
Personally, I think the Scala one feels ugly, but that might only be because both C# options are so readable.
Now Groovy have GINQ , Looks good.
import groovy.transform.*
@TupleConstructor
@EqualsAndHashCode
@ToString
class Person {
String name
String nickname
}
def linda = new Person('Linda', null)
def david = new Person('David', null)
def persons = [new Person('Daniel', 'ShanFengXiaoZi'), linda, david]
def result = GQ {
from p in persons
where p.nickname == null
select p
}.stream()
.peek(p -> { p.nickname = 'Unknown' }) // update `nickname`
.toList()
def expected = [new Person('Linda', 'Unknown'), new Person('David', 'Unknown')]
assert expected == result
assert ['Unknown', 'Unknown'] == [linda, david]*.nickname // ensure the original objects are updated
So i wonder if Scala 3 can support some feature like LINQ, Or learn from Groovy lang.
The QueryDSL was the big missing part of Scala .
http://mail-archives.apache.org/mod_mbox/groovy-notifications/201907.mbox/%[email protected]%3E
[jira] [Updated] (GROOVY-9159) [GEP] Support LINQ, aka GINQ
https://docs.groovy-lang.org/docs/next/html/documentation/#_querying_collections_in_a_sql_like_style
Please consider re-submitting this issue as a feature request.
@netroby You should have a look at Quill, which is better and more powerful.
@liufengyun The quill did not right design. LINQ has it's style. LINQ is unique technology.
I can only see C#, and groovy design the good practice.
I hope scala has the right design practice. Nor Slick ethier Quill.
They were not the same thing equal to LINQ.
I create a new Issue https://github.com/lampepfl/dotty-feature-requests/issues/154
Hope this missing part to be fixed.
The quill did not right design. LINQ has it's style. LINQ is unique technology.
I can only see C#, and groovy design the good practice.
Quill is based on the latest research on Language-Integrated Query (LINQ):
https://github.com/getquill/quill#acknowledgments
If you propose something that is different, you need to justify your claim carefully against the latest research results and implementation (in the feature request).
Most helpful comment
Quill is based on the latest research on Language-Integrated Query (LINQ):
https://github.com/getquill/quill#acknowledgments
If you propose something that is different, you need to justify your claim carefully against the latest research results and implementation (in the feature request).