On Sun, 2010-11-28 at 16:23 -0500, Roman Ivanov wrote:
[ . . . ]
> LINQ _is_ an object API. The query-like syntax is just a misfeature.

or desirable and useful feature!

> But it's not _just_ an object API, because it translates statement into
> expression trees, which can be analyzed and used to generate different
> code or code in a different language.
> 
> Let's say you have a list of objects and need to get only the ones whose
> name starts with "D". You can express the predicate via lambda
> expression: x => x.Name.Length > 0 && x.Name[0] == 'D'. Simple, right?
> Here is the problem. You can apply this expression to every object in
> the list, but you don't always want to. What if it's a database table
> with 10000 records? You don't want to retrieve all those records,
> especially if there is already an index. LINQ allows to analyze the
> lambda function and generate an appropriate SQL query. At lest that how
> I understand it.

This is exactly how things are done in Groovy using builders.  Because
of the met-object protocol the DSL for interacting with SQL is a tree
builder.  The built query gets issued as needed.

The fact that you have an incomplete query just means that the query is
incomplete not that the idea of having a sane language-based DSL instead
of having to build SQL queries with string manipulation is wrong.
Surely using language features to build a query in the knowledge of the
equivalent of well-formedness and validity is better than using string
manipulation and hoping for the best.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:[email protected]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [email protected]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to