If you use the popular code generation tool CodeSmith, you'll want to download the latest beta release. It adds support for .NET 3.5. So now you'll be able to use LINQ in your templates. There are also some code generation performance improvements. Read more about it here.
(Via Rob Howard's blog)