LINQ to Umbraco update

Friday, Mar 20, 2009 3 minute read Tags: LINQ Umbraco LINQ to Umbraco
Hey, thanks for the interest in this post, but just letting you know that it is over 3 years old, so the content in here may not be accurate.

As I mentioned in a previous post I'm working on a LINQ provider for Umbraco, a proper one, not one which is exploiting the operations on LINQ to Objects.

Well I thought I'd do an update on the progress that'd been made thus far on it. This comes on the back of yesterdays post where I eluded to something exciting.

I've completed the main codebase for the DocType Markup Language (DTML) generator last week. Currently it's stuck as a console application which you run, I'm going to be working on the Visual Studio tool, so it can generate like LINQ to SQL does with the DBML. That's proving to be a bit more of a problem than I had hoped, so it's popped on the backburner for the moment. Visual Studio integration is a "nice to have", not a "must have".
The DTML generator, as mentioned, is a console application which runs directly against the Umbraco database. It generates an XML file which represents the DocTypes in your site. This can then be used to generate .NET code in the form of C# of VB.NET (depending on your preferences). Documentation on how to run it will be provided in the future, but there is a help switch for the mean time! :P

But why generate an XML file and a .NET file? Well other than desire to have it work from Visual Studio it provides a different feature. The XSD for the DTML file is available within the LINQ to Umbraco source (and it's 85% of the exported DocType XML), and if you spend the time having a read of it you should be able to work out how to hand-code one of them.
This means that you'll be able to have your classes generated, code written and unit tested, without even having to install Umbraco. This means devs can get started while the UI/ front end guys are putting the site together.

But now for the exciting news, in the last week I've turned my attention to the most important section of the project, the LINQ provider. And in todays commit to Codeplex I added 6 new (passing) tests for LINQ select statements!

*holds for applause*

That's right, there is support for LINQ select statments in both Lambda and Query format. The following works:

  • Select returning type of collection (ctx.CwsHomes)
  • Select returning single property (ctx.CwsHomes.Select(h => h.Bodytext))
  • Select returning annonymous (ctx.CwsHomes.Select(h => new { h.Bodytext, h.CreateDate} ))

True that it's not super useful, there's no filtering yet, but what is done is a good start (and a whole lot sooner than I expected to get it working :P).

I'm not going to provide a package to download, you can get the full source code from the Umbraco project on Codeplex (under the 4.1 branch).