Using .Net 3.5 and C# 3.0 features in T4 templates

The T4 templates are compiled against .Net Framework 2.0 by default and it will be restricted to use LINQ and other .Net 3.5 features in your T4 templates.  If you want to use any of C# 3.0 or .Net 3.5 features in your T4 templates, you have to specify T4 templates language attribute is C#v3.5 instead of C#. The .Net 3.5 features are using System.Core namespace so that you have to give reference to System.Core namespace in the T4 templates.

The below is the syntax

    1 <#@ template language="C#v3.5" hostspecific="True" #>

    2 <#@ assembly name="System.Core" #>


 

2 Comments

  • Brilliant tip Shiju. It solved my problem of using 3.0 syntax in T4 Templates. Thanks a lot

  • Hello,This is a great example. Thanks for rashing.I need to build an Azure web app(ASP.NET). This will have main database in the cloud but some search pages will be accessing the corp net DB. Is that possible?Essentially we need a cloud app which works as if it is installed on the domain/LAN. For example when a user navigates to the app, we should be able to do WindowsAuth and also be able to access AD from this app.Is this possible in the Azure authentication model? Is there a sample app which uses WinAuth?Thanks,Shyam

Comments have been disabled for this content.