Browse Source

-

pull/12/MERGE
sunkaixuan 8 years ago
parent
commit
f7ca4a4b05
  1. 6
      OrmTest/App.config
  2. 2
      OrmTest/Models/Student.cs
  3. 17
      OrmTest/OrmTest.csproj
  4. 2
      OrmTest/OrmTest.csproj.user
  5. 25
      OrmTest/PerformanceTesting/ChloeORMPerformance.cs
  6. 30
      OrmTest/PerformanceTesting/PerformanceBase.cs
  7. 30
      OrmTest/PerformanceTesting/SqlSugarPerformance.cs
  8. 12
      OrmTest/Program.cs
  9. 5
      OrmTest/packages.config

6
OrmTest/App.config

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

2
OrmTest/Models/Student.cs

@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SqlSugar; using SqlSugar;
using System.Linq.Expressions; using System.Linq.Expressions;
using Chloe.Entity;
namespace OrmTest.Models namespace OrmTest.Models
{ {
@ -17,6 +18,7 @@ namespace OrmTest.Models
public int SchoolId { get; set; } public int SchoolId { get; set; }
public DateTime CreateTime { get; set; } public DateTime CreateTime { get; set; }
[SugarColumn(IsIgnore=true)] [SugarColumn(IsIgnore=true)]
[NotMappedAttribute]
public int TestId { get; set; } public int TestId { get; set; }
} }
} }

17
OrmTest/OrmTest.csproj

@ -33,6 +33,18 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Chloe, Version=2.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.SqlServer.2.6.0\lib\net40\Chloe.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Chloe.SqlServer, Version=2.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.SqlServer.2.6.0\lib\net40\Chloe.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SyntacticSugar, Version=2.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SyntacticSugar.2.4.1\lib\net40\SyntacticSugar.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
@ -45,6 +57,9 @@
<ItemGroup> <ItemGroup>
<Compile Include="Config.cs" /> <Compile Include="Config.cs" />
<Compile Include="Models\ViewModelStudent.cs" /> <Compile Include="Models\ViewModelStudent.cs" />
<Compile Include="PerformanceTesting\ChloeORMPerformance.cs" />
<Compile Include="PerformanceTesting\PerformanceBase.cs" />
<Compile Include="PerformanceTesting\SqlSugarPerformance.cs" />
<Compile Include="UnitTest\ExpressionTest\ExpTestBase.cs" /> <Compile Include="UnitTest\ExpressionTest\ExpTestBase.cs" />
<Compile Include="UnitTest\ExpressionTest\Field.cs" /> <Compile Include="UnitTest\ExpressionTest\Field.cs" />
<Compile Include="UnitTest\Query\JoinQuery.cs" /> <Compile Include="UnitTest\Query\JoinQuery.cs" />
@ -59,7 +74,7 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SqlSugar\SqlSugar.csproj"> <ProjectReference Include="..\SqlSugar\SqlSugar.csproj">

2
OrmTest/OrmTest.csproj.user

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView> <ProjectView>ProjectFiles</ProjectView>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

25
OrmTest/PerformanceTesting/ChloeORMPerformance.cs

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Chloe;
using Chloe.SqlServer;
using OrmTest.Models;
namespace OrmTest.PerformanceTesting
{
public class ChloeORMPerformance: PerformanceBase
{
public void Select()
{
MsSqlContext db = new MsSqlContext(Config.ConnectionString);
db.Query<Student>().Select(it => new ViewModelStudent2 { Name = it.Name, Student = it }).ToList();
base.Execute("chloe", () =>
{
var test = db.Query<Student>().Select(it => new ViewModelStudent2 { Name = it.Name, Student = it }).ToList();
});
db.Dispose();
}
}
}

30
OrmTest/PerformanceTesting/PerformanceBase.cs

@ -0,0 +1,30 @@
using SyntacticSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest.PerformanceTesting
{
public class PerformanceBase
{
public int count = 100;
public void Execute(string title, Action fun)
{
PerformanceTest ptef = new PerformanceTest();
ptef.SetCount(count);//执行count次
ptef.Execute(
i =>
{
fun();
},
res =>
{
Console.WriteLine(string.Format("Execute {0} time,{1}{2}", count, title, res));
});
}
}
}

30
OrmTest/PerformanceTesting/SqlSugarPerformance.cs

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using OrmTest.Models;
namespace OrmTest.PerformanceTesting
{
public class SqlSugarPerformance : PerformanceBase
{
public void Select()
{
SqlSugarClient db = new SqlSugarClient(new SystemTablesConfig()
{
ConnectionString = Config.ConnectionString,
DbType = DbType.SqlServer,
IsAutoCloseConnection = false
});
db.IgnoreComumns.Add("TestId", "Student");
db.Queryable<Student>().Select(it => new ViewModelStudent2 { Name = it.Name, Student = it }).ToList();
base.Execute("sqlsuagr", () =>
{
var test = db.Queryable<Student>().Select(it => new ViewModelStudent2 { Name = it.Name, Student = it }).ToList();
});
db.Close();
}
}
}

12
OrmTest/Program.cs

@ -9,6 +9,8 @@ using SqlSugar;
using OrmTest.Models; using OrmTest.Models;
using System.Data.SqlClient; using System.Data.SqlClient;
using OrmTest.UnitTest; using OrmTest.UnitTest;
using OrmTest.PerformanceTesting;
namespace OrmTest namespace OrmTest
{ {
class Program class Program
@ -22,7 +24,15 @@ namespace OrmTest
//new Method(eachCount).Init(); //new Method(eachCount).Init();
//new JoinQuery(eachCount).Init(); //new JoinQuery(eachCount).Init();
//new SingleQuery(eachCount).Init(); //new SingleQuery(eachCount).Init();
new SelectQuery(eachCount).Init(); //new SelectQuery(eachCount).Init();
//Performance Test
for (int i = 0; i < 100; i++)
{
new ChloeORMPerformance().Select();
}
} }
} }
} }

5
OrmTest/packages.config

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Chloe.SqlServer" version="2.6.0" targetFramework="net452" />
<package id="SyntacticSugar" version="2.4.1" targetFramework="net452" />
</packages>
Loading…
Cancel
Save