Files
Yi.Framework/CC.Yi.DALFactory/T4StaticDalFactory.tt
454313500@qq.com 59a42ae48f v1.0.0
2021-03-20 14:12:24 +08:00

43 lines
1.3 KiB
Plaintext

<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.IO" #>
<#@ output extension=".cs" #>
<#
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
string txt;
StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Model.txt");
txt=sr.ReadToEnd();
sr.Close();
string[] ModelData= txt.Split(',');
#>
using CC.Yi.DAL;
using CC.Yi.IDAL;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace CC.Yi.DALFactory
{
public partial class StaticDalFactory
{
<# foreach(string k in ModelData){
#>
public static I<#=k #>Dal Get<#=k #>Dal()
{
I<#=k #>Dal Data = CallContext.GetData("<#=k #>Dal") as I<#=k #>Dal;
if (Data == null)
{
Data = new <#=k #>Dal(DbSessionFactory.GetCurrentDbSession().GetDbContent());
CallContext.SetData("<#=k #>Dal", Data);
}
return Data;
}
<# } #>
}
}