<#@ Template Language="C#" #>
<#@ Assembly Name="System.dll" #>
<#@ Assembly Name="System.Data.dll" #>
<#@ Assembly Name="System.Xml.dll" #>
<#@ Assembly Name="Howest.Guidance.DataAccess.dll" #>
<#@ Assembly Name="Howest.SchemaDiscovery.Common.dll" #>
<#@ Import Namespace="System" #>
<#@ Import Namespace="System.Data" #>
<#@ Import Namespace="System.Xml.Serialization" #>
<#@ Import Namespace="Howest.Guidance.DataAccess.CodeGeneration.ObjectModel" #>
<#@ Import Namespace="Howest.Guidance.DataAccess.CodeGeneration.ObjectModel.Mappings" #>
<#@ Import Namespace="Howest.Guidance.DataAccess.CodeGeneration.ObjectModel.Mappings.Enums" #>
<#@ Import Namespace="Howest.Guidance.DataAccess.CodeGeneration.ObjectModel.NamingConventions" #>
<#@ Import Namespace="Howest.SchemaDiscovery.DbObjects" #>
<#@ Property Processor="PropertyProcessor" Name="Entities"#>
<#@ Property Processor="PropertyProcessor" Name="DataEntityClassNamespace" #>
<#@ include file="Templates\T4\Common\EntityHelper.t4" #>
<#@ include file="Templates\T4\Common\DbTypesHelper.t4" #>
<#@ include file="Templates\T4\Common\NamingHelper.t4" #>
<#@ include file="Templates\T4\Common\MappingFinders.t4" #>

<#
foreach(Entity entity in Entities) 
{#>
// begin "<#= entity.Name #>.cs"
using System;
using System.Collections.Generic;
using System.Text;

namespace <#= this.DataEntityClassNamespace #>
{
    public partial class <#= entity.Name #>
    {
        public <#= entity.Name #>()
        {
        }
        
        public <#= entity.Name #>(<#= GetConstructor(entity) #>)
        {
<# foreach(Property property in entity.Properties)
{
#>
            <#= GetFieldName(property.Name) #> = <#= GetVariableName(property.Name, true) #>;
<#
}
#>
        }
		
<# foreach(Property property in entity.Properties)
{
#>
		private <#= (property.IsNullable && property.Type.IsValueType) ? "Nullable<" + property.Type.ToString() + ">" : property.Type.ToString() #> <#= GetFieldName(property.Name) #>;		
		
	    public <#= (property.IsNullable && property.Type.IsValueType) ? "Nullable<" + property.Type.ToString() + ">" : property.Type.ToString() #> <#= property.Name #>
	    {
	        get { return <#= GetFieldName(property.Name) #>; }
<#
if(!property.ReadOnly)
{
#>
	        set { <#= GetFieldName(property.Name) #> = value; }
<#
}
#>
	    }

<#
}// foreach(Property property in entity.Properties)
#>
    }
}
// end "<#= entity.Name #>.cs"
<#
}// foreach(Entity entity in Entities) 
#>