[Lazarus] SQL parser
Dimitri Smits
smitco at telenet.be
Thu Aug 19 03:49:43 CEST 2010
----- "Michael Van Canneyt" <michael at freepascal.org> schreef:
[snip on usage of new SQL parser]
> >
> > why stop there? Maybe a language-construct like LINQ in .Net for
> dynamic+iteratable resultsets?
>
> As far as I understand it, LINQ does the opposite; it expresses
> iterators in a kind of SQL syntax ?
>
I've only read about it am not a C# (or .net) buff, so I cannot comment on how the language-construct is translated into ITL or "how the magic occurs". Could be that it is an ad-hoc iterator-defintion, or that the statement makes an ad-hoc dynamic, iteratable type that is populated when the statement occurs. Either way, it is a powerful construct that allows one to make a terse 'selection' in an OO way.
Either way, I guess this may not be so easily construed and "translated" into pascal. You need to place the result into a variable. And that variable needs to be typed.
var resultobject : ???
begin
resultobject := from
someobject.tlistproperty, sometdataset, somearray, somesettype
where
someobject.tlistproperty.someotherobject.property=somesettype
and somesettype.value=sstLoaded
and somearry.value=somedataset.fieldbyname('foo').value
and somedataset.fieldbyname('bar').value=someobject.tlistproperty.someotherobject.property2
groupby
somedataset.fieldbyname('foo')
select
new Record(sa := count(somearray.value), sf := somedataset.fieldbyname('foo').value);
...
foreach ...
end;
Anyway, that is probably something that should be discussed in fpc lists then. It is quite a powerful construct. I also believe that it works with providers. Maybe something can be done without going into the language itself through a library and given enough rtti?
kind regards,
Dimitri Smits
More information about the Lazarus
mailing list