mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-21 02:58:05 +08:00
Add T4 DEMO
This commit is contained in:
@@ -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.
|
||||
|
30
Src/Asp.Net/SqlServerTest/T4/SugarTemplate.tt
Normal file
30
Src/Asp.Net/SqlServerTest/T4/SugarTemplate.tt
Normal 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");
|
||||
|
||||
#>
|
1
Src/Asp.Net/SqlServerTest/T4/SugarTemplate1.cs
Normal file
1
Src/Asp.Net/SqlServerTest/T4/SugarTemplate1.cs
Normal file
@@ -0,0 +1 @@
|
||||
|
15
Src/Asp.Net/SqlServerTest/T4/SugarTemplate2.cs
Normal file
15
Src/Asp.Net/SqlServerTest/T4/SugarTemplate2.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -17,8 +17,7 @@ namespace SqlSugar
|
||||
{
|
||||
try
|
||||
{
|
||||
Assembly asmb = Assembly.LoadFrom("Newtonsoft.Json.dll");
|
||||
asmb = CheckAssembly(asmb);
|
||||
JsonHelper.SerializeObject(new { });
|
||||
IsTryJsonNet = true;
|
||||
}
|
||||
catch
|
||||
|
Reference in New Issue
Block a user