XPO and LINQ - first steps

The version of XPO included in our new DXperience 6.3 release includes our first shot at support for LINQ – unsupported and most probably buggy, I should add.

To try it yourself, you must make sure you’re using the correct version of LINQ, or of System.Query.dll to be more precise. The version you need is included in the August 2006 CTP of ADO.NET vNext, and to install that, you’ll need to have the LINQ May 2006 CTP installed first. When creating a project, be sure to reference the System.Query.dll that is part of ADO.NET vNext – the GAC will still contain a reference to the LINQ CTP one, and the Visual Studio templates in the LINQ Preview category also reference the wrong version. There are templates in Visual Studio that you can use, in the category ADO.NET vNext CTP – whichever way you go, you should make sure that the referenced System.Query.dll is in the ADO.NET vNext CTP installation directory, by default at C:\Program Files\Microsoft SDKs\ADO.NET vNext CTP\Bin\System.Query.dll.

Now, in addition to the standard assemblies required for XPO, you must add a reference to the assembly DevExpress.Xpo.v6.3.Query.dll. This can be found in the GAC, but it’s shown as DevExpress.Xpo.Linq, confusingly. There’s only one of those around, so once you find it, you should be fine :-)

With all that in place, you should now be able to write code like this:

using (UnitOfWork unitOfWork = new UnitOfWork()) {
var albums =
from album in new XPQuery<Album>(unitOfWork)
where album.Year == 1974
select album;
...
}

Let me repeat, this is currently in development. Feel free to let us know if you encounter really unexpected or inexplicable behaviour, but that is to be expected at this point. Have fun with this early preview!