I am trying to get the If else statement to compute the value based off the object passed in from the loop. This template worked until i added in the if else block and it says it can't be used as a statement. Thoughts??
<#@ template language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="CookieCutterDT" #>
<#@ import namespace="CookieCutterBL.DT_Template" #>
namespace <#= NameSpace #>
{
public class <#= ClassName #>
{
<#
foreach(ColumnDT c in Columns)
{#>
public <# if (c.IsNullable && c.DataType != "string" && c.DataType != "string []") { c.DataType + "?"; } else { c.DataType; } #> <#= c.ColumnName #> { get; set; };
<#
}
#>
}
}
The if else is checking if the column is a nullable field and if it is, make it's datatype also nullable in C#.