From 8d4272ea1a221d2dfff6f669342fc2aebe6ae1dd Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 7 Aug 2017 13:34:05 +0800 Subject: [PATCH] - --- .../SqlServerTest/src/SqlServerTest/Demos/1_Query.cs | 4 ++-- .../SqlServerTest/src/SqlServerTest/Demos/3_Insert.cs | 10 +++++----- .../SqlServerTest/src/SqlServerTest/Demos/7_Filter.cs | 2 +- .../src/SqlServerTest/UnitTest/DataTest.cs | 2 +- .../src/SqlServerTest/UnitTest/Mapping .cs | 2 +- .../src/SqlServerTest/UnitTest/Query/JoinQuery.cs | 6 +++--- .../src/SqlServerTest/UnitTest/Query/SelectQuery.cs | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/Demos/1_Query.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/Demos/1_Query.cs index 9041108f1..b01d79cc3 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/Demos/1_Query.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/Demos/1_Query.cs @@ -189,7 +189,7 @@ namespace OrmTest.Demo .Where((st, sc) => st.Id == 1 && sc.Id == 2).ToList(); //SELECT [st].[Id],[st].[SchoolId],[st].[Name],[st].[CreateTime] FROM [Student] st - //Left JOIN School sc ON ( [st].[SchoolId] = [sc].[Id] ) + //Left JOIN [School] sc ON ( [st].[SchoolId] = [sc].[Id] ) //WHERE ( [sc].[Id] = @Id0 ) AND ( [st].[Id] = @Id1 ) AND (( [st].[Id] = @Id2 ) AND ( [sc].[Id] = @Id3 )) @@ -315,7 +315,7 @@ namespace OrmTest.Demo .Where("st.id>@id") .AddParameters(new { id = 1 }) .Select("st.*").ToList(); - //SELECT st.* FROM [Student] st Left JOIN School sh ON sh.id=st.schoolid WHERE st.id>@id + //SELECT st.* FROM [Student] st Left JOIN [School] sh ON sh.id=st.schoolid WHERE st.id>@id } private static void Enum() { diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/Demos/3_Insert.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/Demos/3_Insert.cs index c9e52329a..7ec172b12 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/Demos/3_Insert.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/Demos/3_Insert.cs @@ -21,20 +21,20 @@ namespace OrmTest.Demo var t2 = db.Insertable(insertObj).ExecuteCommand(); //Insert reutrn Identity Value - var t3 = db.Insertable(insertObj).ExecuteReutrnIdentity(); + var t3 = db.Insertable(insertObj).ExecuteReturnIdentity(); //Only insert Name and SchoolId - var t4 = db.Insertable(insertObj).InsertColumns(it => new { it.Name, it.SchoolId }).ExecuteReutrnIdentity(); - var t4_1 = db.Insertable(insertObj).InsertColumns(it => it=="Name"||it== "SchoolId").ExecuteReutrnIdentity(); + var t4 = db.Insertable(insertObj).InsertColumns(it => new { it.Name, it.SchoolId }).ExecuteReturnIdentity(); + var t4_1 = db.Insertable(insertObj).InsertColumns(it => it=="Name"||it== "SchoolId").ExecuteReturnIdentity(); //Ignore TestId - var t5 = db.Insertable(insertObj).IgnoreColumns(it => new { it.Name, it.TestId }).ExecuteReutrnIdentity(); + var t5 = db.Insertable(insertObj).IgnoreColumns(it => new { it.Name, it.TestId }).ExecuteReturnIdentity(); //Ignore TestId - var t6 = db.Insertable(insertObj).IgnoreColumns(it => it == "Name" || it == "TestId").ExecuteReutrnIdentity(); + var t6 = db.Insertable(insertObj).IgnoreColumns(it => it == "Name" || it == "TestId").ExecuteReturnIdentity(); //Use Lock diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/Demos/7_Filter.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/Demos/7_Filter.cs index 273f6f814..00b7dc9da 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/Demos/7_Filter.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/Demos/7_Filter.cs @@ -22,7 +22,7 @@ namespace OrmTest.Demo var sql2 = db.Queryable((f, s) => new object[] { JoinType.Left, f.SchoolId == s.Id }).ToSql(); //SELECT[f].[ID],[f].[SchoolId],[f].[Name],[f].[CreateTime] - //FROM[STudent] f Left JOIN School s ON([f].[SchoolId] = [s].[Id]) WHERE f.isDelete=0 + //FROM[STudent] f Left JOIN [School] s ON([f].[SchoolId] = [s].[Id]) WHERE f.isDelete=0 //Specify name filter diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/DataTest.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/DataTest.cs index c0d28941e..a5bd769bb 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/DataTest.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/DataTest.cs @@ -38,7 +38,7 @@ namespace OrmTest.UnitTest Varbinary2 = null, String = "string" }; - var id = db.Insertable(insertObject).ExecuteReutrnIdentity(); + var id = db.Insertable(insertObject).ExecuteReturnIdentity(); var data = db.Queryable().InSingle(id); if ( insertObject.Datetime1.ToString("yyyy-MM-dd HH:mm:ss") != data.Datetime1.ToString("yyyy-MM-dd HH:mm:ss") || diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/Mapping .cs b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/Mapping .cs index d54e02a4e..a00b8e4f3 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/Mapping .cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/Mapping .cs @@ -32,7 +32,7 @@ namespace OrmTest.UnitTest .GroupBy(st => st.Id) .GroupBy((st,sc) => sc.Id).OrderBy(st => st.Id,OrderByType.Asc) .Select((st,sc)=> new { stid=st.Id,scid=sc.Id}).ToSql(); - base.Check(@"SELECT [st].[ID] AS [stid] , [sc].[id] AS [scid] FROM [STudent] st Left JOIN School sc ON ( [st].[SchoolId] = [sc].[id] ) WHERE ( [st].[ID] = @Id0 ) AND ( [sc].[id] = @Id1 ) AND ( [sc].[id] = [st].[ID] )GROUP BY [st].[ID],[sc].[id] ORDER BY [st].[ID] ASC ", + base.Check(@"SELECT [st].[ID] AS [stid] , [sc].[id] AS [scid] FROM [STudent] st Left JOIN [School] sc ON ( [st].[SchoolId] = [sc].[id] ) WHERE ( [st].[ID] = @Id0 ) AND ( [sc].[id] = @Id1 ) AND ( [sc].[id] = [st].[ID] )GROUP BY [st].[ID],[sc].[id] ORDER BY [st].[ID] ASC ", null, t2.Key, null, " Mapping t2 error"); var x2 = GetInstance(); } diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/Query/JoinQuery.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/Query/JoinQuery.cs index 0cc74061f..3e943679e 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/Query/JoinQuery.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/Query/JoinQuery.cs @@ -36,7 +36,7 @@ namespace OrmTest.UnitTest .Where("st.id>@id") .AddParameters(new { id = 1 }) .Select("st.*").ToSql(); - string sql = @"SELECT st.* FROM [Student] st Left JOIN School sh ON sh.id=st.schoolid WHERE st.id>@id "; + string sql = @"SELECT st.* FROM [Student] st Left JOIN [School] sh ON sh.id=st.schoolid WHERE st.id>@id "; base.Check(sql,new List() {new SugarParameter("@id",1)}, join3.Key, join3.Value, "join 3 Error"); } } @@ -48,7 +48,7 @@ namespace OrmTest.UnitTest var join1 = db.Queryable((st, sc) => new object[] { JoinType.Left,st.SchoolId==sc.Id }).Where(st => st.Id > 0).Select("*").ToSql(); - base.Check(@"SELECT * FROM [STudent] st Left JOIN School sc ON ( [st].[SchoolId] = [sc].[Id] ) WHERE ( [st].[ID] > @Id0 ) ", + base.Check(@"SELECT * FROM [STudent] st Left JOIN [School] sc ON ( [st].[SchoolId] = [sc].[Id] ) WHERE ( [st].[ID] > @Id0 ) ", new List() { new SugarParameter("@Id0",0) }, join1.Key, join1.Value, "join 1 Error"); @@ -61,7 +61,7 @@ namespace OrmTest.UnitTest var join2 = db.Queryable((st, sc) => new object[] { JoinType.Left,st.SchoolId==sc.Id }).Where(st => st.Id > 2).Select("*").ToSql(); - base.Check(@"SELECT * FROM [STudent] st Left JOIN School sc ON ( [st].[SchoolId] = [sc].[Id] ) WHERE ( [st].[ID] > @Id0 ) ", + base.Check(@"SELECT * FROM [STudent] st Left JOIN [School] sc ON ( [st].[SchoolId] = [sc].[Id] ) WHERE ( [st].[ID] > @Id0 ) ", new List() { new SugarParameter("@Id0",2) }, join2.Key, join2.Value, "join 2 Error"); diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/Query/SelectQuery.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/Query/SelectQuery.cs index 3154e896d..73a6fc1ab 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/Query/SelectQuery.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlServerTest/UnitTest/Query/SelectQuery.cs @@ -50,7 +50,7 @@ namespace OrmTest.UnitTest var t1 = db.Queryable((st, sc) => new object[] { JoinType.Inner,st.Id==sc.Id }).GroupBy(st => st.Id).Having(st => SqlFunc.AggregateAvg(st.Id) == 1).Select(st => new { avgId = SqlFunc.AggregateAvg(st.Id) }).ToSql(); - base.Check("SELECT AVG([st].[ID]) AS [avgId] FROM [STudent] st Inner JOIN School sc ON ( [st].[ID] = [sc].[Id] ) GROUP BY [st].[ID] HAVING (AVG([st].[ID]) = @Const0 ) ", + base.Check("SELECT AVG([st].[ID]) AS [avgId] FROM [STudent] st Inner JOIN [School] sc ON ( [st].[ID] = [sc].[Id] ) GROUP BY [st].[ID] HAVING (AVG([st].[ID]) = @Const0 ) ", new List() { new SugarParameter("@Const0",1) } @@ -64,7 +64,7 @@ namespace OrmTest.UnitTest .Where(st => st.Id > 0) .Select((st, st2) => new { stid = st.Id, scId = st2.Id, xx = st }).ToSql(); - base.Check("SELECT [st].[Id] AS [stid] , [st2].[Id] AS [scId] , [st].[Id] AS [School.Id] , [st].[Name] AS [School.Name] FROM [School] st Left JOIN School st2 ON ( [st].[Id] = [st2].[Id] ) WHERE ( [st].[Id] > @Id0 ) " + base.Check("SELECT [st].[Id] AS [stid] , [st2].[Id] AS [scId] , [st].[Id] AS [School.Id] , [st].[Name] AS [School.Name] FROM [School] st Left JOIN [School] st2 ON ( [st].[Id] = [st2].[Id] ) WHERE ( [st].[Id] > @Id0 ) " , new List() { new SugarParameter("@Id0",0) }, t2.Key, t2.Value, "select t2 Error"); @@ -75,7 +75,7 @@ namespace OrmTest.UnitTest JoinType.Left,sc2.Id==sc.Id }).Where(st => st.Id > 0) .Select((st) => new School() { Id = st.Id }).ToSql(); - base.Check("SELECT [st].[ID] AS [Id] FROM [STudent] st Left JOIN School sc ON ( [st].[SchoolId] = [sc].[Id] ) Left JOIN School sc2 ON ( [sc2].[Id] = [sc].[Id] ) WHERE ( [st].[ID] > @Id0 ) ", + base.Check("SELECT [st].[ID] AS [Id] FROM [STudent] st Left JOIN [School] sc ON ( [st].[SchoolId] = [sc].[Id] ) Left JOIN [School] sc2 ON ( [sc2].[Id] = [sc].[Id] ) WHERE ( [st].[ID] > @Id0 ) ", new List() { new SugarParameter("@Id0",0) }, t3.Key, t3.Value, "select t3 Error");