On 10/11/2011 4:07 AM, Jacob Carlborg wrote:
I think that the use of opDispatch and selecting with a struct should be
available at the higher level interfaces and not in the low level
interface.
What do you mean by this? Do you mean instead of having the opDispatch
in the Connection class, we'd have it in a separate struct / template /
other magic? This would allow us to utilize this method for other
sources of data, such as XML.
On the other hand though, this doesn't add a whole lot. Let's say we had
this code:
auto rows = db.execute("SELECT score, a.user FROM users a JOIN scores b
on a.user = b.user");
foreach (row; rows) {
writeln(to!int(row["score"]));
}
We could also add in a generic range operation that converts a range of
Variant[string] (a row) to a struct specified by the user. The code
would become:
auto rows = extractStructs!(MyStruct, db.execute("SELECT score, a.user
FROM users a JOIN scores b on a.user = b.user"));
foreach (row; rows) {
writeln(row.score);
}
I suppose I'm just remembering how much plumbing code had to be done
when accessing databases in C#. It sounds like doing this from D will be
much easier, even without my silly "LINQ" concept.