diff --git a/Src/Asp.Net/PerformanceTest/Config.cs b/Src/Asp.Net/PerformanceTest/Config.cs
index aa84a1639..3ea771c69 100644
--- a/Src/Asp.Net/PerformanceTest/Config.cs
+++ b/Src/Asp.Net/PerformanceTest/Config.cs
@@ -8,7 +8,7 @@ namespace PerformanceTest
{
public class Config
{
- public static string connectionString = "server=.;uid=sa;pwd=sasa;database=SqlSugarTest";
+ public static string connectionString = "server=.;uid=sa;pwd=haosql;database=SqlSugarTest";
public static ConnectionConfig SugarConfig =new ConnectionConfig() { IsAutoCloseConnection=true,InitKeyType = InitKeyType.SystemTable, ConnectionString = Config.connectionString, DbType = DbType.SqlServer };
public static SqlSugarClient GetSugarConn()
{
diff --git a/Src/Asp.Net/PerformanceTest/Dabase/test.sql b/Src/Asp.Net/PerformanceTest/Dabase/test.sql
deleted file mode 100644
index dbc6c239b..000000000
--- a/Src/Asp.Net/PerformanceTest/Dabase/test.sql
+++ /dev/null
@@ -1,54 +0,0 @@
-CREATE TABLE [dbo].[Test](
- [Id] [int] IDENTITY(1,1) NOT NULL,
- [F_Byte] [tinyint] NULL,
- [F_Int16] [smallint] NULL,
- [F_Int32] [int] NULL,
- [F_Int64] [bigint] NULL,
- [F_Double] [float] NULL,
- [F_Float] [real] NULL,
- [F_Decimal] [decimal](18, 0) NULL,
- [F_Bool] [bit] NULL,
- [F_DateTime] [datetime] NULL,
- [F_Guid] [uniqueidentifier] NULL,
- [F_String] [nvarchar](100) NULL,
- CONSTRAINT [PK_Test] PRIMARY KEY CLUSTERED
-(
- [Id] ASC
-)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
-) ON [PRIMARY]
-
-GO
-
-declare @i int = 0;
-
-begin tran;
-while(@i<=1000000)
-begin
-INSERT INTO [dbo].[Test]
- ([F_Byte]
- ,[F_Int16]
- ,[F_Int32]
- ,[F_Int64]
- ,[F_Double]
- ,[F_Float]
- ,[F_Decimal]
- ,[F_Bool]
- ,[F_DateTime]
- ,[F_Guid]
- ,[F_String])
- VALUES
- (1
- ,2
- ,@i
- ,@i
- ,@i
- ,@i
- ,@i
- ,@i%2
- ,GETDATE()
- ,NEWID()
- ,'Chloe' + CAST(@i AS nvarchar(1000))
- )
-set @i=@i+1;
-end
-commit;
\ No newline at end of file
diff --git a/Src/Asp.Net/PerformanceTest/Models/TestEntity.cs b/Src/Asp.Net/PerformanceTest/Models/TestEntity.cs
index 3e2587779..f6d4a1ae1 100644
--- a/Src/Asp.Net/PerformanceTest/Models/TestEntity.cs
+++ b/Src/Asp.Net/PerformanceTest/Models/TestEntity.cs
@@ -11,6 +11,7 @@ namespace PerformanceTest
public class Test
{
[Dapper.Contrib.Extensions.Key]
+ [SqlSugar.SugarColumn(IsIdentity =true ,IsPrimaryKey =true)]
public int Id { get; set; }
public byte? F_Byte { get; set; }
public Int16? F_Int16 { get; set; }
diff --git a/Src/Asp.Net/PerformanceTest/PerformanceTest.csproj b/Src/Asp.Net/PerformanceTest/PerformanceTest.csproj
index 2d5ad8deb..a832ed490 100644
--- a/Src/Asp.Net/PerformanceTest/PerformanceTest.csproj
+++ b/Src/Asp.Net/PerformanceTest/PerformanceTest.csproj
@@ -49,8 +49,8 @@
..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll
True
-
- ..\SqliteTest\OtherDll\SyntacticSugar.dll
+
+ ..\packages\SyntacticSugar.2.4.1\lib\net40\SyntacticSugar.dll
@@ -78,9 +78,6 @@
-
-
-
{489bb790-226c-4fad-8d1e-51d72a7ff8e5}
diff --git a/Src/Asp.Net/PerformanceTest/Program.cs b/Src/Asp.Net/PerformanceTest/Program.cs
index a6f9cfebe..4d3cd1b99 100644
--- a/Src/Asp.Net/PerformanceTest/Program.cs
+++ b/Src/Asp.Net/PerformanceTest/Program.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using PerformanceTest.TestItems;
+using SqlSugar;
namespace PerformanceTest
{
@@ -15,7 +16,9 @@ namespace PerformanceTest
///
static void Main(string[] args)
{
- var type = DemoType.GetAll;
+ InitData();
+
+ var type = DemoType.GetById;
var ormType = OrmType.Dapper;
switch (type)
{
@@ -33,6 +36,40 @@ namespace PerformanceTest
}
Console.ReadKey();
}
+
+ private static void InitData()
+ {
+ SqlSugarClient conn = Config.GetSugarConn();
+ conn.CurrentConnectionConfig.InitKeyType = InitKeyType.Attribute;
+ conn.DbMaintenance.CreateDatabase();//创建库
+ conn.CodeFirst.InitTables();
+ List test = new List();
+ if (conn.Queryable().Count() < 100000)
+ {
+ Console.WriteLine("初始化数据");
+
+ for (int i = 0; i < 100000; i++)
+ {
+ test.Add(new Test()
+ {
+ F_Bool = true,
+ F_Byte = 0,
+ F_DateTime = DateTime.Now,
+ F_Decimal = 1,
+ F_Double = 11,
+ F_Float = 11,
+ F_Guid = Guid.Empty,
+ F_String = "abc",
+ F_Int16 = 1,
+ F_Int32 = 1,
+ F_Int64 = 1
+
+ });
+ }
+ }
+ conn.Insertable(test).ExecuteCommand();
+ }
+
enum DemoType
{
GetAll,
diff --git a/Src/Asp.Net/PerformanceTest/TestItems/TestGetAll.cs b/Src/Asp.Net/PerformanceTest/TestItems/TestGetAll.cs
index f9e65acf9..d185749bb 100644
--- a/Src/Asp.Net/PerformanceTest/TestItems/TestGetAll.cs
+++ b/Src/Asp.Net/PerformanceTest/TestItems/TestGetAll.cs
@@ -15,7 +15,7 @@ namespace PerformanceTest.TestItems
public void Init(OrmType type)
{
Database.SetInitializer(null);
- Console.WriteLine("测试一次读取100万条数据的速度");
+ Console.WriteLine("测试一次读取10万条数据的速度");
var eachCount = 1;
var beginDate = DateTime.Now;
diff --git a/Src/Asp.Net/PerformanceTest/packages.config b/Src/Asp.Net/PerformanceTest/packages.config
index 5b0ea3221..8a9b79671 100644
--- a/Src/Asp.Net/PerformanceTest/packages.config
+++ b/Src/Asp.Net/PerformanceTest/packages.config
@@ -4,4 +4,5 @@
+
\ No newline at end of file