<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ include file=".\EntityHelper.ttinclude" #>
<#@ include file=".\T4Manager.ttinclude" #>
<#     
    // 数据库连接
    var connectionString = @"server=192.168.18.166;database=db_performance;uid=root;pwd=1234qwer;port=3306;";

    // 需要解析的数据库
    var database = new List<string> { "db_performance" };
	
	DirectoryInfo directory = new DirectoryInfo(Host.TemplateFile);
	var outputPath = Path.Combine(directory.Parent.Parent.FullName,"Repository");
	new DirectoryInfo(outputPath).Create();

    var manager = new Manager(Host, GenerationEnvironment, true) { OutputPath = outputPath };
    var entities = EntityHelper.GetEntities(connectionString, database);

    foreach(Entity entity in entities)
    {
		var entityName = entity.EntityName.Replace("sys_","").Replace("_","");
		entityName = "Perfor" + entityName.Substring(0,1).ToUpper() + entityName.Substring(1); 
        manager.StartBlock(entityName + "Repository.cs");
#>
//-----------------------------------------------------------------------
// <copyright file=" <#= entity.EntityName #>.cs">
// * FileName: <#= entity.EntityName #>.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using Performance.EntityModels;

namespace Performance.Repository
{
    /// <summary>
    /// <#= entity.EntityName #> Repository
    /// </summary>
    public partial class <#= entityName #>Repository : PerforRepository<<#= entity.EntityName #>>
    {
		public <#= entityName #>Repository(PerformanceDbContext context) : base(context)
        {
        }
    }
}
<#        
        manager.EndBlock(); 
    }

    manager.Process(true);
#>
