Is it possible to use LINQ in win32 DELPHI applications
Delphi 2009 has generics, class helpers and anonymous method support, but not lambda, extension methods or type inference. Lambda expressions are probably coming in a future version of Delphi, but they are not on the official road map yet (a new one should be coming soon hopefully). Also Delphi for Win32 does not have access to all the LINQ libraries.
So the short answer is NO, you can't do LINQ in Win32 Delphi. You can how ever do some similar things, and you can technically even access LINQ through COM (as you can with any .NET classes), but it would kind of defeat the point without the cool LINQ syntax.
LINQ is really a .NET technology. While Delphi will most likely develop the language features that make LINQ possible, the underlying .NET libraries are for .NET development only.
I would suggest using RemObject Data Abstract or similar.
Yes and No. LINQ can really be thought of as two different items.
The first is the SQL like query syntax. It's what allows you to write the following in C#.
var query = from it in "foobar" select Char.ToUpper(it);
For delphi to use this version of LINQ, it would need to add explicit syntax support. AFAIK this does not exist.
Under the hood though, all LINQ queries are translated into a set of query expressions. These typically involve a heavy use of lambda expressions and closures. The above code is equivalent to the following non-SQL syntax version.
var query = "foobar".Select(x => Char.ToUpper(x));
I don't know the level of lambda or delegate support in Delphi but it should be possible to access LINQ in this method from Delphi.
I don't know in what version of Delphi it appeared, but in XE we have 'object functions' that can be made as closures or near equal lambda expressions.
So, as of today (26/06/2011) it is near possible to have LINQ-like expressions in Delphi (the 2nd form).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With