T4 trouble compiling transformation
Posted
by John Leidegren
on Stack Overflow
See other posts from Stack Overflow
or by John Leidegren
Published on 2010-05-09T19:18:35Z
Indexed on
2010/05/19
5:10 UTC
Read the original article
Hit count: 222
T4
|visual-studio-2010
I can't figure this one out. Why doesn't T4 locate the IEnumerable
type? I'm using Visual Studio 2010. And I just hope someone knows why?
<#@ template debug="true" hostspecific="false" language="C#" #>
<#@ assembly name="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Data" #>
<#@ import namespace="System.Data.SqlClient" #>
<#@ output extension=".cs" #>
public static class Tables
{
<#
var q = @"
SELECT
tbl.name 'table',
col.name 'column'
FROM
sys.tables tbl
INNER JOIN
sys.columns col ON col.object_id = tbl.object_id
";
// var source = Execute(q);
#>
}
<#+
static IEnumerable Execute(string cmdText)
{
using (var conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=t4build;Integrated Security=True;"))
{
conn.Open();
var cmd = new SqlCommand(cmdText, conn);
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
}
}
}
}
#>
Error 2 Compiling transformation: The type or namespace name 'IEnumerable' could not be found (are you missing a using directive or an assembly reference?) c:\Projects\T4BuildApp\T4BuildApp\TextTemplate1.tt 26 9
© Stack Overflow or respective owner