From 8df102e19ab94c11050d05ee49b400c93dcec5d0 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 29 Sep 2017 10:56:37 +0800 Subject: [PATCH] Update Demo --- Src/Asp.Net/PerformanceTest/Config.cs | 2 +- Src/Asp.Net/PerformanceTest/Program.cs | 2 +- Src/Asp.Net/PerformanceTest/TestItems/TestGetSql.cs | 4 +--- .../SqlSugar/Infrastructure/InstanceFactory.cs | 11 +++++++++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Src/Asp.Net/PerformanceTest/Config.cs b/Src/Asp.Net/PerformanceTest/Config.cs index 3d186e335..aa84a1639 100644 --- a/Src/Asp.Net/PerformanceTest/Config.cs +++ b/Src/Asp.Net/PerformanceTest/Config.cs @@ -9,7 +9,7 @@ namespace PerformanceTest public class Config { public static string connectionString = "server=.;uid=sa;pwd=sasa;database=SqlSugarTest"; - public static ConnectionConfig SugarConfig =new ConnectionConfig() { InitKeyType = InitKeyType.SystemTable, ConnectionString = Config.connectionString, DbType = DbType.SqlServer }; + public static ConnectionConfig SugarConfig =new ConnectionConfig() { IsAutoCloseConnection=true,InitKeyType = InitKeyType.SystemTable, ConnectionString = Config.connectionString, DbType = DbType.SqlServer }; public static SqlSugarClient GetSugarConn() { return new SqlSugarClient(SugarConfig); diff --git a/Src/Asp.Net/PerformanceTest/Program.cs b/Src/Asp.Net/PerformanceTest/Program.cs index 61c0373fd..29668938d 100644 --- a/Src/Asp.Net/PerformanceTest/Program.cs +++ b/Src/Asp.Net/PerformanceTest/Program.cs @@ -16,7 +16,7 @@ namespace PerformanceTest static void Main(string[] args) { var type = DemoType.GetSql; - var ormType = OrmType.SqlSugar; + var ormType = OrmType.Dapper; switch (type) { case DemoType.GetAll: diff --git a/Src/Asp.Net/PerformanceTest/TestItems/TestGetSql.cs b/Src/Asp.Net/PerformanceTest/TestItems/TestGetSql.cs index cc643766f..9b0abc860 100644 --- a/Src/Asp.Net/PerformanceTest/TestItems/TestGetSql.cs +++ b/Src/Asp.Net/PerformanceTest/TestItems/TestGetSql.cs @@ -44,10 +44,8 @@ namespace PerformanceTest.TestItems PerHelper.Execute(eachCount, "SqlSugar", () => { - using (SqlSugarClient conn = Config.GetSugarConn()) - { + SqlSugarClient conn = Config.GetSugarConn(); var list2 = conn.Ado.SqlQuery("select top 20 * from Test"); ; - } }); } diff --git a/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs b/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs index c272a5bb4..13c58d8d9 100644 --- a/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs +++ b/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs @@ -246,8 +246,15 @@ namespace SqlSugar public static IAdo GetAdo(ConnectionConfig currentConnectionConfig) { - IAdo result = CreateInstance(GetClassName(currentConnectionConfig.DbType.ToString(), "Provider")); - return result; + if (currentConnectionConfig.DbType == DbType.SqlServer) + { + return new SqlServerProvider(); + } + else + { + IAdo result = CreateInstance(GetClassName(currentConnectionConfig.DbType.ToString(), "Provider")); + return result; + } } private static string GetClassName(string type, string name)