2007/12/09

Ambition vs. LINQ

If you would be given the opportunity to choose your data query abstraction language from those two examples:

LINQ:
products.Where(p => p.Category == "Food").OrderBy(p => p.Price).Select(p => p.Name).Take(2);


Ambition:
Product.select {|p| p.category == "Food" }.sort_by { &:price }.map{ &:name }.first(2)


Which of these implementations would you prefer? I really like them both, though the second one is even more concise.

2 comments:

Marco Studer said...

I prefer this :var result = (from p in Produts where p.Category == "Food" orderby p.Price select p.Name).First(2)

Christoph Hilty said...

Implicit Syntax. That' why I took an example with '.First()' which in my opinion breaks the flow of the implicit syntax.