Add T4 DEMO

This commit is contained in:
sunkaixuan
2017-09-13 13:21:26 +08:00
parent 54b082e75b
commit b6093b734d
5 changed files with 60 additions and 2 deletions

View File

@@ -65,6 +65,12 @@
<Compile Include="Models\ViewModelStudent.cs" />
<Compile Include="PerformanceTesting\PerformanceBase.cs" />
<Compile Include="PerformanceTesting\SqlSugarPerformance.cs" />
<Compile Include="T4\SugarTemplate1.cs" />
<Compile Include="T4\SugarTemplate2.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>SugarTemplate.tt</DependentUpon>
</Compile>
<Compile Include="UnitTest\DataTest.cs" />
<Compile Include="UnitTest\Delete.cs" />
<Compile Include="UnitTest\EnumTest.cs" />
@@ -97,6 +103,13 @@
<ItemGroup>
<Content Include="DataBase\script.sql" />
<Content Include="OtherDll\SyntacticSugar.dll" />
<Content Include="T4\SugarTemplate.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>SugarTemplate2.cs</LastGenOutput>
</Content>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -0,0 +1,30 @@
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="System.Xml.Linq" #>
<#@ assembly name="System.Data" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="SqlSugar" #>
<#@ import namespace="Newtonsoft.Json" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Web" #>
<#@ assembly name="$(SolutionDir)\SqlSugar\References\Newtonsoft.Json.dll" #>
<#@ assembly name="$(SolutionDir)\SqlSugar\bin\Debug\SqlSugar.dll" #>
<#
//CTRL+S将会执行该文件的代码自动作生实体
JsonConvert.SerializeObject(new{});
//当前项目目录
string projectDir = Host.ResolveAssemblyReference("$(ProjectDir)");
//解决方案目录
string solutionDir = Host.ResolveAssemblyReference("$(SolutionDir)");
var db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = "server=.;uid=sa;pwd=sasa;database=SqlSugar4XTest", DbType = DbType.SqlServer, IsAutoCloseConnection = true });
db.DbFirst.CreateClassFile("c:\\T4");
#>

View File

@@ -0,0 +1 @@


View File

@@ -0,0 +1,15 @@


View File

@@ -17,8 +17,7 @@ namespace SqlSugar
{
try
{
Assembly asmb = Assembly.LoadFrom("Newtonsoft.Json.dll");
asmb = CheckAssembly(asmb);
JsonHelper.SerializeObject(new { });
IsTryJsonNet = true;
}
catch