On 11/12/2013 06:38 AM, John Colvin wrote:
On Tuesday, 12 November 2013 at 13:50:49 UTC, Jacob Carlborg wrote:
auto person = Person.where(e => e.name == "John");
Translates to:
select * from person where name = 'John'
for those of us entirely unfamiliar with linq, what is this supposed to
do? Select people with name "John" from a collection of people, like in
sql? It seems trivial to do this using filter, or am I missing
something...?
linq provides an interface to query any collection, but what is
interesting in this case is
Person.where(e => e.name == "John")
invokes an engine that builds the necessary sql to issue an equivalent
query to your sql database and assembles the results into a range of
Person. And it can do this for any arbitrary predicate (well, almost. It
doesn't handle function calls to arbitrary code too well).
the .NET framework can do this because it exposes an api for querying,
building, and compiling asts.
D cannot do this because it doesn't. (and I have tried to make it work)