This commit is contained in:
sunkaixuan 2017-09-21 14:46:29 +08:00
parent c34232ab43
commit 9524dbce95
4 changed files with 11 additions and 5 deletions

View File

@ -1,4 +1,5 @@
using System;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -8,5 +9,9 @@ namespace PerformanceTest
public class Config
{
public static string connectionString = "server=.;uid=sa;pwd=sasa;database=SqlSugarTest";
public static SqlSugarClient GetSugarConn()
{
return new SqlSugarClient(new ConnectionConfig() { InitKeyType = InitKeyType.SystemTable, ConnectionString = Config.connectionString, DbType = DbType.SqlServer });
}
}
}

View File

@ -40,13 +40,14 @@ namespace PerformanceTest.TestItems
PerHelper.Execute(eachCount, "SqlSugar", () =>
{
using (SqlSugarClient conn = new SqlSugarClient(new ConnectionConfig() { InitKeyType=InitKeyType.SystemTable, ConnectionString= Config.connectionString, DbType=DbType.SqlServer }))
using (SqlSugarClient conn = Config.GetSugarConn())
{
var list2 = conn.Queryable<Test>().ToList();
}
});
}
private static void Dapper(int eachCount)
{
GC.Collect();//回收资源

View File

@ -40,7 +40,7 @@ namespace PerformanceTest.TestItems
PerHelper.Execute(eachCount, "SqlSugar", () =>
{
using (SqlSugarClient conn = new SqlSugarClient(new ConnectionConfig() { InitKeyType = InitKeyType.SystemTable, ConnectionString = Config.connectionString, DbType = DbType.SqlServer }))
using (SqlSugarClient conn = Config.GetSugarConn())
{
var list2 = conn.Queryable<Test>().InSingle(1);
}

View File

@ -38,7 +38,7 @@ namespace PerformanceTest.TestItems
PerHelper.Execute(eachCount, "SqlSugar", () =>
{
using (SqlSugarClient conn = new SqlSugarClient(new ConnectionConfig() { InitKeyType = InitKeyType.SystemTable, ConnectionString = Config.connectionString, DbType = DbType.SqlServer }))
using (SqlSugarClient conn = Config.GetSugarConn())
{
var list2 = conn.Ado.SqlQuery<Test>("select top 10 * from Test"); ;
}