NewGaoKaoApi/New_College.FrameWork/New_College.FrameWork.Services/New_College.FrameWork.Servi...

159 lines
4.1 KiB
Plaintext

<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ output extension=".cs" #>
<#@ assembly name="System.Core.dll" #>
<#@ assembly name="System.Data.dll" #>
<#@ assembly name="System.Data.DataSetExtensions.dll" #>
<#@ assembly name="System.Xml.dll" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Xml" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Data" #>
<#@ import namespace="System.Data.SqlClient" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.IO" #>
<#@ include file="$(ProjectDir)DbHelper.ttinclude" #>
<#@ include file="$(ProjectDir)ModelAuto.ttinclude" #>
<# var manager = new Manager(Host, GenerationEnvironment, true); #>
<#
var OutputPath1 =Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Host.TemplateFile+"..")+"..")+"..");
OutputPath1=Path.Combine(OutputPath1,"New_College.Services","Services_New");
if (!Directory.Exists(OutputPath1))
{
Directory.CreateDirectory(OutputPath1);
}
#>
//--------------------------------------------------------------------
// 此代码由T4模板自动生成
// 生成时间 <#=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")#>
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
//--------------------------------------------------------------------
<#
var tableName=config.TableName;
#>
<#
if(tableName!=""){
#>
using System;
using System.Threading.Tasks;
using New_College.Common;
using New_College.IRepository;
using New_College.IRepository.Base;
using New_College.IRepository.UnitOfWork;
using New_College.IServices;
using New_College.Model.Models;
using New_College.Services.BASE;
namespace New_College.Services
{
/// <summary>
/// <#=tableName#>Services
/// </summary>
public class <#=tableName#>Services : BaseServices<<#=tableName#>>, I<#=tableName#>Services
{
IBaseRepository<<#=tableName#>> dal;
public <#=tableName#>Services(IBaseRepository<<#=tableName#>> dal)
{
this.dal = dal;
base.baseDal = dal;
}
}
}
<#
} else{
#>
<#
SqlConnection conn = new SqlConnection(config.ConnectionString);
conn.Open();
System.Data.DataTable schema = conn.GetSchema("TABLES");
#>
<#
foreach(System.Data.DataRow row in schema.Rows)
{
manager.StartBlock(row["TABLE_NAME"].ToString()+"Services"+".cs",OutputPath1);
#>
//----------<#=row["TABLE_NAME"].ToString()#>开始----------
using System;
using System.Threading.Tasks;
using New_College.Common;
using New_College.IRepository;
using New_College.IRepository.UnitOfWork;
using New_College.IRepository.Base;
using New_College.IServices;
using New_College.Model.Models;
using New_College.Services.BASE;
namespace New_College.Services
{
/// <summary>
/// <#=row["TABLE_NAME"].ToString()#>Services
/// </summary>
public class <#=row["TABLE_NAME"].ToString()#>Services : BaseServices<<#=row["TABLE_NAME"].ToString()#>>, I<#=row["TABLE_NAME"].ToString() #>Services
{
IBaseRepository<<#=row["TABLE_NAME"].ToString() #>> dal;
public <#=row["TABLE_NAME"].ToString() #>Services(IBaseRepository<<#=row["TABLE_NAME"].ToString() #>> dal)
{
this.dal = dal;
base.baseDal = dal;
}
}
}
//----------<#=row["TABLE_NAME"].ToString()#>结束----------
<#
manager.EndBlock();
}
{
manager.StartBlock("BaseServices.cs",OutputPath1);//文件名
#>
//----------开始----------
using System;
using System.Threading.Tasks;
using New_College.Common;
using New_College.IRepository;
using New_College.IRepository.UnitOfWork;
using New_College.IRepository.Base;
using New_College.IServices;
using New_College.Model.Models;
using New_College.Services.BASE;
namespace New_College.Services
{
/// <summary>
/// IBaseRepository
/// </summary>
public class BaseServices<TEntity> : IBaseServices<TEntity> where TEntity : class, new()
{
public IBaseRepository<TEntity> baseDal;
}
}
//----------结束----------
<#
manager.EndBlock();
}
manager.Process(true);
}
#>