From 3974c35b2ffd7e294afdcff4a88de11e137ca495 Mon Sep 17 00:00:00 2001 From: 28810 <28810@YEXIANGQIN> Date: Sat, 16 Mar 2019 08:00:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E5=B1=9E=E6=80=A7=E8=A7=84?= =?UTF-8?q?=E5=88=99=E5=88=B6=E7=BA=A6=E3=80=81ISelect=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20AsSelect=20=E7=94=A8=E4=BA=8E=E9=9B=86=E5=90=88?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E8=BF=9B=E8=A1=8C=E5=AD=90=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=EF=BC=8C=E8=87=AA=E5=8A=A8=E8=81=94=E8=A1=A8=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8AMySql=E5=AE=9E=E7=8E=B0=E4=B8=8E?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FreeSql.Site.UI/wwwroot/file/select.md | 48 +- FreeSql.Tests/MySql/Curd/MySqlSelectTest.cs | 264 ++++---- .../MySql/MySqlExpression/ConvertTest.cs | 4 +- .../MySql/MySqlExpression/DateTimeTest.cs | 197 +++--- .../MySql/MySqlExpression/MathTest.cs | 2 +- .../MySql/MySqlExpression/StringTest.cs | 245 ++++---- .../MySql/MySqlExpression/TimeSpanTest.cs | 58 +- FreeSql.Tests/Oracle/Curd/OracleSelectTest.cs | 250 ++++---- .../Oracle/OracleExpression/ConvertTest.cs | 4 +- .../Oracle/OracleExpression/DateTimeTest.cs | 196 +++--- .../Oracle/OracleExpression/MathTest.cs | 2 +- .../Oracle/OracleExpression/StringTest.cs | 244 ++++---- .../Oracle/OracleExpression/TimeSpanTest.cs | 58 +- .../PostgreSQL/Curd/PostgreSQLSelectTest.cs | 256 ++++---- .../PostgreSQLExpression/ConvertTest.cs | 4 +- .../PostgreSQLExpression/DateTimeTest.cs | 196 +++--- .../PostgreSQLExpression/MathTest.cs | 2 +- .../PostgreSQLExpression/StringTest.cs | 244 ++++---- .../PostgreSQLExpression/TimeSpanTest.cs | 58 +- .../SqlServer/Curd/SqlServerInsertTest.cs | 28 +- .../SqlServer/Curd/SqlServerSelectTest.cs | 248 ++++---- .../SqlServer/Curd/SqlServerUpdateTest.cs | 12 +- .../SqlServerExpression/ConvertTest.cs | 2 +- .../SqlServerExpression/DateTimeTest.cs | 2 +- .../SqlServer/SqlServerExpression/MathTest.cs | 2 +- .../SqlServerExpression/StringTest.cs | 2 +- .../SqlServerExpression/TimeSpanTest.cs | 2 +- FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs | 252 ++++---- FreeSql.Tests/Sqlite/Curd/SqliteUpdateTest.cs | 12 +- .../Sqlite/SqliteExpression/ConvertTest.cs | 4 +- .../Sqlite/SqliteExpression/DateTimeTest.cs | 196 +++--- .../Sqlite/SqliteExpression/MathTest.cs | 2 +- .../Sqlite/SqliteExpression/StringTest.cs | 244 ++++---- .../Sqlite/SqliteExpression/TimeSpanTest.cs | 58 +- FreeSql.Tests/UnitTest1.cs | 43 +- FreeSql/Internal/CommonExpression.cs | 159 ++++- .../SelectProvider/Select0Provider.cs | 52 +- .../SelectProvider/Select10Provider.cs | 145 ++++- .../SelectProvider/Select1Provider.cs | 168 +++++- .../SelectProvider/Select3Provider.cs | 138 ++++- .../SelectProvider/Select4Provider.cs | 139 ++++- .../SelectProvider/Select5Provider.cs | 140 ++++- .../SelectProvider/Select6Provider.cs | 141 ++++- .../SelectProvider/Select7Provider.cs | 142 ++++- .../SelectProvider/Select8Provider.cs | 143 ++++- .../SelectProvider/Select9Provider.cs | 144 ++++- FreeSql/Internal/Model/SelectTableInfo.cs | 6 +- FreeSql/Internal/Model/TableInfo.cs | 34 ++ FreeSql/Internal/UtilsExpressionTree.cs | 568 ++++++++++-------- FreeSql/MySql/Curd/MySqlSelect.cs | 38 +- FreeSql/Oracle/Curd/OracleSelect.cs | 16 +- FreeSql/PostgreSQL/Curd/PostgreSQLSelect.cs | 16 +- FreeSql/SqlServer/Curd/SqlServerSelect.cs | 16 +- FreeSql/Sqlite/Curd/SqliteSelect.cs | 16 +- 54 files changed, 3423 insertions(+), 2239 deletions(-) diff --git a/Examples/website/FreeSql.Site.UI/wwwroot/file/select.md b/Examples/website/FreeSql.Site.UI/wwwroot/file/select.md index cc4bd3e4..f30755f8 100644 --- a/Examples/website/FreeSql.Site.UI/wwwroot/file/select.md +++ b/Examples/website/FreeSql.Site.UI/wwwroot/file/select.md @@ -13,7 +13,7 @@ class Topic { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -45,28 +45,28 @@ StartsWith, EndsWith, Contains, ToLower, ToUpper, Substring, Length, IndexOf, Pa ### 单表 ```csharp var sql = select.Where(a => a.Id == 10).ToSql(); -///SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a WHERE (a.`Id` = 10) +///SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a WHERE (a.`Id` = 10) sql = select.Where(a => a.Id == 10 && a.Id > 10 || a.Clicks > 100).ToSql(); -///SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a WHERE (a.`Id` = 10 AND a.`Id` > 10 OR a.`Clicks` > 100) +///SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a WHERE (a.`Id` = 10 AND a.`Id` > 10 OR a.`Clicks` > 100) ``` ### 多表,使用导航属性 ```csharp -sql = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid).ToSql(); -///SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TestTypeInfoGuid`) +sql = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid).ToSql(); +///SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TypeGuid`) sql = select.Where(a => a.Type.Parent.Name == "tparent").ToSql(); -//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeInfo` a__Type, `TestTypeParentInfo` a__Type__Parent WHERE (a__Type__Parent.`Name` = 'tparent') +//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeInfo` a__Type, `TestTypeParentInfo` a__Type__Parent WHERE (a__Type__Parent.`Name` = 'tparent') ``` ### 多表,没有导航属性 ```csharp -sql = select.Where((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "typeTitle").ToSql(); -//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeInfo` b WHERE (b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'typeTitle') +sql = select.Where((a, b) => b.Guid == a.TypeGuid && b.Name == "typeTitle").ToSql(); +//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeInfo` b WHERE (b.`Guid` = a.`TypeGuid` AND b.`Name` = 'typeTitle') sql = select.Where((a, b, c) => c.Name == "tparent").ToSql(); -//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a, `TestTypeParentInfo` c WHERE (c.`Name` = 'tparent') +//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a, `TestTypeParentInfo` c WHERE (c.`Name` = 'tparent') ``` ### 多表,任意查 @@ -74,13 +74,13 @@ sql = select.Where((a, b, c) => c.Name == "tpa sql = select.From((s, b, c) => s .Where(a => a.Id == 10 && c.Name == "xxx") .Where(a => b.ParentId == 20)).ToSql(); -//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeParentInfo` c, `TestTypeInfo` b WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20) +//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeParentInfo` c, `TestTypeInfo` b WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20) ``` ### 原生SQL ```csharp sql = select.Where("a.clicks > 100 && a.id = ?id", new { id = 10 }).ToSql(); -//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a WHERE (a.clicks > 100 && a.id = ?id) +//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a WHERE (a.clicks > 100 && a.id = ?id) ``` > 以上条件查询,支持 WhereIf @@ -89,38 +89,38 @@ sql = select.Where("a.clicks > 100 && a.id = ?id", new { id = 10 }).ToSql(); ### 使用导航属性联表 ```csharp -sql = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid).ToSql(); -//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` +sql = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).ToSql(); +//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` sql = select - .LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .LeftJoin(a => a.Type.Guid == a.TypeGuid) .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId).ToSql(); -//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId` +//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId` ``` ### 没有导航属性联表 ```csharp -sql = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid).ToSql(); -//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid` +sql = select.LeftJoin((a, b) => b.Guid == a.TypeGuid).ToSql(); +//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` sql = select - .LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .LeftJoin((a, b) => b.Guid == a.TypeGuid) .LeftJoin((a, c) => c.Id == a.Type.ParentId).ToSql(); -//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid` LEFT JOIN `TestTypeParentInfo` c ON c.`Id` = b.`ParentId` +//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` LEFT JOIN `TestTypeParentInfo` c ON c.`Id` = b.`ParentId` ``` ### 联表任意查 ```csharp sql = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id)).ToSql(); -//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON a.`TestTypeInfoGuid` = b.`Guid` LEFT JOIN `TestTypeParentInfo` c ON b.`ParentId` = c.`Id` +//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON a.`TypeGuid` = b.`Guid` LEFT JOIN `TestTypeParentInfo` c ON b.`ParentId` = c.`Id` ``` ### 原生SQL联表 ```csharp -sql = select.LeftJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname", new { bname = "xxx" }).ToSql(); -//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a LEFT JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname +sql = select.LeftJoin("TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = ?bname", new { bname = "xxx" }).ToSql(); +//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a LEFT JOIN TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = ?bname ``` # 查询数据 @@ -132,7 +132,7 @@ List t1 = select.Where(a => a.Id > 0).Skip(100).Limit(200).ToList(); ### 返回 List + 导航属性的数据 ```csharp -List t2 = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid).ToList(); +List t2 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).ToList(); //此时会返回普通字段 + 导航对象 Type 的数据 ``` diff --git a/FreeSql.Tests/MySql/Curd/MySqlSelectTest.cs b/FreeSql.Tests/MySql/Curd/MySqlSelectTest.cs index 051898f8..acbd8378 100644 --- a/FreeSql.Tests/MySql/Curd/MySqlSelectTest.cs +++ b/FreeSql.Tests/MySql/Curd/MySqlSelectTest.cs @@ -16,7 +16,8 @@ namespace FreeSql.Tests.MySql { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + [Column(OldName = "TypeGuid")] + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -111,8 +112,8 @@ namespace FreeSql.Tests.MySql { var t2 = g.mysql.Select().As("b").Where("").Where(a => a.Id > 0).Skip(100).Limit(200).ToSql(); - var sql1 = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid).ToSql(); - var sql2 = select.LeftJoin((a, b) => a.TestTypeInfoGuid == b.Guid && b.Name == "111").ToSql(); + var sql1 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).ToSql(); + var sql2 = select.LeftJoin((a, b) => a.TypeGuid == b.Guid && b.Name == "111").ToSql(); var sql3 = select.LeftJoin("TestTypeInfo b on b.Guid = a.TypeGuid").ToSql(); //g.mysql.Select().Join((a, b, c) => new Model.JoinResult3( @@ -127,14 +128,14 @@ namespace FreeSql.Tests.MySql { //.Where(a => a.Id == 1).ToSql(); var sql4 = select.From((s, b, c) => s - .InnerJoin(a => a.TestTypeInfoGuid == b.Guid) + .InnerJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => c.Id == b.ParentId) .Where(a => b.Name == "xxx")).ToSql(); //.Where(a => a.Id == 1).ToSql(); var list111 = select.From((s, b, c) => s - .InnerJoin(a => a.TestTypeInfoGuid == b.Guid) + .InnerJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => c.Id == b.ParentId) .Where(a => b.Name != "xxx")); var list111sql = list111.ToSql(); @@ -207,7 +208,7 @@ namespace FreeSql.Tests.MySql { var sql2222Tolist = sql2222.ToList(); var collectionSelect = select.Where(a => - a.Type.Guid == a.TestTypeInfoGuid && + a.Type.Guid == a.TypeGuid && a.Type.Parent.Id == a.Type.ParentId && a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any(b => b.ParentId == a.Type.Parent.Id) ); @@ -238,216 +239,223 @@ namespace FreeSql.Tests.MySql { public void From() { //������� var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id) ); var sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON a.`TestTypeInfoGuid` = b.`Guid` LEFT JOIN `TestTypeParentInfo` c ON b.`ParentId` = c.`Id`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON a.`TypeGuid` = b.`Guid` LEFT JOIN `TestTypeParentInfo` c ON b.`ParentId` = c.`Id`", sql); query2.ToList(); } [Fact] public void LeftJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid`", sql); + //Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` WHERE (a__Type.`Guid` = a.`TypeGuid`)", sql); query.ToList(); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` AND a__Type.`Name` = 'xxx'", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` AND a__Type.`Name` = 'xxx'", sql); query.ToList(); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON 1 = 1 LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` AND a__Type.`Name` = 'xxx' WHERE (a__Type__Parent.`Id` = 10)", sql); + //Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON 1 = 1 LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` AND a__Type.`Name` = 'xxx' WHERE (a__Type__Parent.`Id` = 10)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` AND a__Type.`Name` = 'xxx' LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId` WHERE (a__Type__Parent.`Id` = 10)", sql); query.ToList(); //���û�е������� - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid`", sql); query.ToList(); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'xxx'", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` AND b.`Name` = 'xxx'", sql); query.ToList(); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeParentInfo` b__Parent ON 1 = 1 LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'xxx' WHERE (b__Parent.`Id` = 10)", sql); + //Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeParentInfo` b__Parent ON 1 = 1 LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` AND b.`Name` = 'xxx' WHERE (b__Parent.`Id` = 10)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` AND b.`Name` = 'xxx' LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId` WHERE (a__Type__Parent.`Id` = 10)", sql); query.ToList(); //������� query = select - .LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .LeftJoin(a => a.Type.Guid == a.TypeGuid) .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId`", sql); query.ToList(); query = select - .LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .LeftJoin((a, b) => b.Guid == a.TypeGuid) .LeftJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid` LEFT JOIN `TestTypeParentInfo` c ON c.`Id` = b.`ParentId`", sql); + //Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` LEFT JOIN `TestTypeParentInfo` c ON c.`Id` = b.`ParentId`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON 1 = 1 LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` LEFT JOIN `TestTypeParentInfo` c ON c.`Id` = a__Type.`ParentId`", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON a.`TestTypeInfoGuid` = b.`Guid` LEFT JOIN `TestTypeParentInfo` c ON b.`ParentId` = c.`Id`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON a.`TypeGuid` = b.`Guid` LEFT JOIN `TestTypeParentInfo` c ON b.`ParentId` = c.`Id`", sql); query2.ToList(); //������϶����㲻�� - query = select.LeftJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid"); + query = select.LeftJoin("TestTypeInfo b on b.Guid = a.TypeGuid"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN TestTypeInfo b on b.Guid = a.TypeGuid", sql); query.ToList(); - query = select.LeftJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname", new { bname = "xxx" }); + query = select.LeftJoin("TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = ?bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = ?bname", sql); query.ToList(); } [Fact] public void InnerJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid`", sql); query.ToList(); - query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` AND a__Type.`Name` = 'xxx'", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` AND a__Type.`Name` = 'xxx'", sql); query.ToList(); - query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON 1 = 1 INNER JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` AND a__Type.`Name` = 'xxx' WHERE (a__Type__Parent.`Id` = 10)", sql); + //Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON 1 = 1 INNER JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` AND a__Type.`Name` = 'xxx' WHERE (a__Type__Parent.`Id` = 10)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` AND a__Type.`Name` = 'xxx' LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId` WHERE (a__Type__Parent.`Id` = 10)", sql); query.ToList(); //���û�е������� - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid`", sql); query.ToList(); - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'xxx'", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` AND b.`Name` = 'xxx'", sql); query.ToList(); - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeParentInfo` b__Parent ON 1 = 1 INNER JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'xxx' WHERE (b__Parent.`Id` = 10)", sql); + //Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeParentInfo` b__Parent ON 1 = 1 INNER JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` AND b.`Name` = 'xxx' WHERE (b__Parent.`Id` = 10)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` AND b.`Name` = 'xxx' LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId` WHERE (a__Type__Parent.`Id` = 10)", sql); query.ToList(); //������� query = select - .InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .InnerJoin(a => a.Type.Guid == a.TypeGuid) .InnerJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` INNER JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` INNER JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId`", sql); query.ToList(); query = select - .InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .InnerJoin((a, b) => b.Guid == a.TypeGuid) .InnerJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid` INNER JOIN `TestTypeParentInfo` c ON c.`Id` = b.`ParentId`", sql); + //Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` INNER JOIN `TestTypeParentInfo` c ON c.`Id` = b.`ParentId`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` a__Type ON 1 = 1 INNER JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` LEFT JOIN `TestTypeParentInfo` c ON c.`Id` = a__Type.`ParentId`", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .InnerJoin(a => a.TestTypeInfoGuid == b.Guid) + .InnerJoin(a => a.TypeGuid == b.Guid) .InnerJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` b ON a.`TestTypeInfoGuid` = b.`Guid` INNER JOIN `TestTypeParentInfo` c ON b.`ParentId` = c.`Id`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN `TestTypeInfo` b ON a.`TypeGuid` = b.`Guid` INNER JOIN `TestTypeParentInfo` c ON b.`ParentId` = c.`Id`", sql); query2.ToList(); //������϶����㲻�� - query = select.InnerJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid"); + query = select.InnerJoin("TestTypeInfo b on b.Guid = a.TypeGuid"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN TestTypeInfo b on b.Guid = a.TypeGuid", sql); query.ToList(); - query = select.InnerJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname", new { bname = "xxx" }); + query = select.InnerJoin("TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = ?bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a INNER JOIN TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = ?bname", sql); query.ToList(); } [Fact] public void RightJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.RightJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid`", sql); query.ToList(); - query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.RightJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` AND a__Type.`Name` = 'xxx'", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` AND a__Type.`Name` = 'xxx'", sql); query.ToList(); - query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.RightJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON 1 = 1 RIGHT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` AND a__Type.`Name` = 'xxx' WHERE (a__Type__Parent.`Id` = 10)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON 1 = 1 RIGHT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` AND a__Type.`Name` = 'xxx' WHERE (a__Type__Parent.`Id` = 10)", sql); query.ToList(); //���û�е������� - query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.RightJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid`", sql); query.ToList(); - query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.RightJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'xxx'", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` AND b.`Name` = 'xxx'", sql); query.ToList(); - query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.RightJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeParentInfo` b__Parent ON 1 = 1 RIGHT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'xxx' WHERE (b__Parent.`Id` = 10)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a LEFT JOIN `TestTypeParentInfo` b__Parent ON 1 = 1 RIGHT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` AND b.`Name` = 'xxx' WHERE (b__Parent.`Id` = 10)", sql); query.ToList(); //������� query = select - .RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .RightJoin(a => a.Type.Guid == a.TypeGuid) .RightJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` RIGHT JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TypeGuid` RIGHT JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId`", sql); query.ToList(); query = select - .RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .RightJoin((a, b) => b.Guid == a.TypeGuid) .RightJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid` RIGHT JOIN `TestTypeParentInfo` c ON c.`Id` = b.`ParentId`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TypeGuid` RIGHT JOIN `TestTypeParentInfo` c ON c.`Id` = b.`ParentId`", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .RightJoin(a => a.TestTypeInfoGuid == b.Guid) + .RightJoin(a => a.TypeGuid == b.Guid) .RightJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` b ON a.`TestTypeInfoGuid` = b.`Guid` RIGHT JOIN `TestTypeParentInfo` c ON b.`ParentId` = c.`Id`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN `TestTypeInfo` b ON a.`TypeGuid` = b.`Guid` RIGHT JOIN `TestTypeParentInfo` c ON b.`ParentId` = c.`Id`", sql); query2.ToList(); //������϶����㲻�� - query = select.RightJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid"); + query = select.RightJoin("TestTypeInfo b on b.Guid = a.TypeGuid"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN TestTypeInfo b on b.Guid = a.TypeGuid", sql); query.ToList(); - query = select.RightJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname", new { bname = "xxx" }); + query = select.RightJoin("TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = ?bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a RIGHT JOIN TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = ?bname", sql); query.ToList(); } @@ -456,48 +464,48 @@ namespace FreeSql.Tests.MySql { //����е�������a.Type��a.Type.Parent ���ǵ������� var query = select.Where(a => a.Id == 10); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.`Id` = 10)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.`Id` = 10)", sql); query.ToList(); query = select.Where(a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.`Id` = 10 AND a.`Id` > 10 OR a.`Clicks` > 100)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.`Id` = 10 AND a.`Id` > 10 OR a.`Clicks` > 100)", sql); query.ToList(); query = select.Where(a => a.Id == 10).Where(a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.`Id` = 10) AND (a.`Clicks` > 100)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.`Id` = 10) AND (a.`Clicks` > 100)", sql); query.ToList(); query = select.Where(a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle')", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle')", sql); query.ToList(); - query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TestTypeInfoGuid`)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TypeGuid`)", sql); query.ToList(); query = select.Where(a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type, `TestTypeParentInfo` a__Type__Parent WHERE (a__Type__Parent.`Name` = 'tparent')", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type, `TestTypeParentInfo` a__Type__Parent WHERE (a__Type__Parent.`Name` = 'tparent')", sql); query.ToList(); //���û�е������ԣ��򵥶������ - query = select.Where((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "typeTitle"); + query = select.Where((a, b) => b.Guid == a.TypeGuid && b.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` b WHERE (b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'typeTitle')", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` b WHERE (b.`Guid` = a.`TypeGuid` AND b.`Name` = 'typeTitle')", sql); query.ToList(); - query = select.Where((a, b) => b.Name == "typeTitle" && b.Guid == a.TestTypeInfoGuid); + query = select.Where((a, b) => b.Name == "typeTitle" && b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` b WHERE (b.`Name` = 'typeTitle' AND b.`Guid` = a.`TestTypeInfoGuid`)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` b WHERE (b.`Name` = 'typeTitle' AND b.`Guid` = a.`TypeGuid`)", sql); query.ToList(); query = select.Where((a, b, c) => c.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeParentInfo` c WHERE (c.`Name` = 'tparent')", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeParentInfo` c WHERE (c.`Name` = 'tparent')", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -505,13 +513,13 @@ namespace FreeSql.Tests.MySql { .Where(a => a.Id == 10 && c.Name == "xxx") .Where(a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeParentInfo` c, `TestTypeInfo` b WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeParentInfo` c, `TestTypeInfo` b WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20)", sql); query2.ToList(); //������϶����㲻�� query = select.Where("a.clicks > 100 and a.id = ?id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.clicks > 100 and a.id = ?id)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.clicks > 100 and a.id = ?id)", sql); query.ToList(); } [Fact] @@ -519,32 +527,32 @@ namespace FreeSql.Tests.MySql { //����е�������a.Type��a.Type.Parent ���ǵ������� var query = select.WhereIf(true, a => a.Id == 10); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.`Id` = 10)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.`Id` = 10)", sql); query.ToList(); query = select.WhereIf(true, a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.`Id` = 10 AND a.`Id` > 10 OR a.`Clicks` > 100)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.`Id` = 10 AND a.`Id` > 10 OR a.`Clicks` > 100)", sql); query.ToList(); query = select.WhereIf(true, a => a.Id == 10).WhereIf(true, a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.`Id` = 10) AND (a.`Clicks` > 100)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.`Id` = 10) AND (a.`Clicks` > 100)", sql); query.ToList(); query = select.WhereIf(true, a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle')", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle')", sql); query.ToList(); - query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TestTypeInfoGuid`)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TypeGuid`)", sql); query.ToList(); query = select.WhereIf(true, a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type, `TestTypeParentInfo` a__Type__Parent WHERE (a__Type__Parent.`Name` = 'tparent')", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type, `TestTypeParentInfo` a__Type__Parent WHERE (a__Type__Parent.`Name` = 'tparent')", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -552,13 +560,13 @@ namespace FreeSql.Tests.MySql { .WhereIf(true, a => a.Id == 10 && c.Name == "xxx") .WhereIf(true, a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeParentInfo` c, `TestTypeInfo` b WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeParentInfo` c, `TestTypeInfo` b WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20)", sql); query2.ToList(); //������϶����㲻�� query = select.WhereIf(true, "a.clicks > 100 and a.id = ?id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.clicks > 100 and a.id = ?id)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a WHERE (a.clicks > 100 and a.id = ?id)", sql); query.ToList(); // ==========================================WhereIf(false) @@ -566,32 +574,32 @@ namespace FreeSql.Tests.MySql { //����е�������a.Type��a.Type.Parent ���ǵ������� query = select.WhereIf(false, a => a.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); query.ToList(); query = select.WhereIf(false, a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); query.ToList(); query = select.WhereIf(false, a => a.Id == 10).WhereIf(false, a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); query.ToList(); query = select.WhereIf(false, a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); query.ToList(); - query = select.WhereIf(false, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.WhereIf(false, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); query.ToList(); query = select.WhereIf(false, a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -599,13 +607,13 @@ namespace FreeSql.Tests.MySql { .WhereIf(false, a => a.Id == 10 && c.Name == "xxx") .WhereIf(false, a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); query2.ToList(); //������϶����㲻�� query = select.WhereIf(false, "a.clicks > 100 and a.id = ?id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a", sql); query.ToList(); } [Fact] @@ -681,59 +689,59 @@ namespace FreeSql.Tests.MySql { }; //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid).AsTable(tableRule); + var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).AsTable(tableRule); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` a__Type ON a__Type.`Guid` = a.`TypeGuid`", sql); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").AsTable(tableRule); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` AND a__Type.`Name` = 'xxx'", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` a__Type ON a__Type.`Guid` = a.`TypeGuid` AND a__Type.`Name` = 'xxx'", sql); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeParentInfoAsTable` a__Type__Parent ON 1 = 1 LEFT JOIN `TestTypeInfoAsTable2` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` AND a__Type.`Name` = 'xxx' WHERE (a__Type__Parent.`Id` = 10)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeParentInfoAsTable` a__Type__Parent ON 1 = 1 LEFT JOIN `TestTypeInfoAsTable2` a__Type ON a__Type.`Guid` = a.`TypeGuid` AND a__Type.`Name` = 'xxx' WHERE (a__Type__Parent.`Id` = 10)", sql); //���û�е������� - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid).AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` b ON b.`Guid` = a.`TestTypeInfoGuid`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` b ON b.`Guid` = a.`TypeGuid`", sql); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` b ON b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'xxx'", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` b ON b.`Guid` = a.`TypeGuid` AND b.`Name` = 'xxx'", sql); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeParentInfoAsTable` b__Parent ON 1 = 1 LEFT JOIN `TestTypeInfoAsTable2` b ON b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'xxx' WHERE (b__Parent.`Id` = 10)", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeParentInfoAsTable` b__Parent ON 1 = 1 LEFT JOIN `TestTypeInfoAsTable2` b ON b.`Guid` = a.`TypeGuid` AND b.`Name` = 'xxx' WHERE (b__Parent.`Id` = 10)", sql); //������� query = select - .LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .LeftJoin(a => a.Type.Guid == a.TypeGuid) .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` LEFT JOIN `TestTypeParentInfoAsTable` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` a__Type ON a__Type.`Guid` = a.`TypeGuid` LEFT JOIN `TestTypeParentInfoAsTable` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId`", sql); query = select - .LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .LeftJoin((a, b) => b.Guid == a.TypeGuid) .LeftJoin((a, c) => c.Id == a.Type.ParentId).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` b ON b.`Guid` = a.`TestTypeInfoGuid` LEFT JOIN `TestTypeParentInfoAsTable` c ON c.`Id` = b.`ParentId`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` b ON b.`Guid` = a.`TypeGuid` LEFT JOIN `TestTypeParentInfoAsTable` c ON c.`Id` = b.`ParentId`", sql); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id)).AsTable(tableRule); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` b ON a.`TestTypeInfoGuid` = b.`Guid` LEFT JOIN `TestTypeParentInfoAsTable` c ON b.`ParentId` = c.`Id`", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN `TestTypeInfoAsTable2` b ON a.`TypeGuid` = b.`Guid` LEFT JOIN `TestTypeParentInfoAsTable` c ON b.`ParentId` = c.`Id`", sql); //������϶����㲻�� - query = select.LeftJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid").AsTable(tableRule); + query = select.LeftJoin("TestTypeInfo b on b.Guid = a.TypeGuid").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN TestTypeInfo b on b.Guid = a.TypeGuid", sql); - query = select.LeftJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname", new { bname = "xxx" }).AsTable(tableRule); + query = select.LeftJoin("TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = ?bname", new { bname = "xxx" }).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname", sql); + Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topicAsTable1` a LEFT JOIN TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = ?bname", sql); } } } diff --git a/FreeSql.Tests/MySql/MySqlExpression/ConvertTest.cs b/FreeSql.Tests/MySql/MySqlExpression/ConvertTest.cs index ee7ddd82..6f2a3c52 100644 --- a/FreeSql.Tests/MySql/MySqlExpression/ConvertTest.cs +++ b/FreeSql.Tests/MySql/MySqlExpression/ConvertTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.MySqlExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -36,7 +36,7 @@ namespace FreeSql.Tests.MySqlExpression { public void ToBoolean() { var data = new List(); data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 2) > 0).ToList()); - //SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` + //SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` //FROM `tb_topic` a //WHERE ((a.`Clicks` not in ('0','false'))) } diff --git a/FreeSql.Tests/MySql/MySqlExpression/DateTimeTest.cs b/FreeSql.Tests/MySql/MySqlExpression/DateTimeTest.cs index c59e34e0..36c929b6 100644 --- a/FreeSql.Tests/MySql/MySqlExpression/DateTimeTest.cs +++ b/FreeSql.Tests/MySql/MySqlExpression/DateTimeTest.cs @@ -14,13 +14,14 @@ namespace FreeSql.Tests.MySqlExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } } [Table(Name = "TestTypeInfo333")] class TestTypeInfo { + [Column(IsIdentity = true)] public int Guid { get; set; } public int ParentId { get; set; } public TestTypeParentInfo Parent { get; set; } @@ -39,7 +40,7 @@ namespace FreeSql.Tests.MySqlExpression { public void Now() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.Now.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(now(), '%Y-%m-%d') as datetime)) } @@ -47,7 +48,7 @@ namespace FreeSql.Tests.MySqlExpression { public void UtcNow() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.UtcNow.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(utc_timestamp(), '%Y-%m-%d') as datetime)) } @@ -55,7 +56,7 @@ namespace FreeSql.Tests.MySqlExpression { public void MinValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.MinValue.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(cast('0001/1/1 0:00:00' as datetime), '%Y-%m-%d') as datetime)) } @@ -63,7 +64,7 @@ namespace FreeSql.Tests.MySqlExpression { public void MaxValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.MaxValue.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(cast('9999/12/31 23:59:59' as datetime), '%Y-%m-%d') as datetime)) } @@ -73,29 +74,29 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.Date == DateTime.Now.Date).ToList()); data.Add(select.Where(a => a.Type.Time.Date > DateTime.Now.Date).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Date > DateTime.Now.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(now(), '%Y-%m-%d') as datetime)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (cast(date_format(a__Type.`Time`, '%Y-%m-%d') as datetime) > cast(date_format(now(), '%Y-%m-%d') as datetime)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (cast(date_format(a__Type__Parent.`Time2`, '%Y-%m-%d') as datetime) > cast(date_format(now(), '%Y-%m-%d') as datetime)); data.Add(select.Where(a => DateTime.Now.Subtract(a.CreateTime.Date).TotalSeconds > 0).ToList()); data.Add(select.Where(a => DateTime.Now.Subtract(a.Type.Time.Date).TotalSeconds > 0).ToList()); data.Add(select.Where(a => DateTime.Now.Subtract(a.Type.Parent.Time2.Date).TotalSeconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((timestampdiff(microsecond, cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((timestampdiff(microsecond, cast(date_format(a__Type.`Time`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((timestampdiff(microsecond, cast(date_format(a__Type__Parent.`Time2`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0) } @@ -105,15 +106,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.TimeOfDay == DateTime.Now.TimeOfDay).ToList()); data.Add(select.Where(a => a.Type.Time.TimeOfDay > DateTime.Now.TimeOfDay).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.TimeOfDay > DateTime.Now.TimeOfDay).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((timestampdiff(microsecond, date_format(a__Type.`Time`, '1970-1-1 %H:%i:%s.%f'), a__Type.`Time`) + 62135596800000000) > (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((timestampdiff(microsecond, date_format(a__Type__Parent.`Time2`, '1970-1-1 %H:%i:%s.%f'), a__Type__Parent.`Time2`) + 62135596800000000) > (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)) } @@ -123,15 +124,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); data.Add(select.Where(a => a.Type.Time.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((dayofweek(a.`CreateTime`) - 1) > (dayofweek(now()) - 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((dayofweek(a__Type.`Time`) - 1) > (dayofweek(now()) - 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((dayofweek(a__Type__Parent.`Time2`) - 1) > (dayofweek(now()) - 1)) } @@ -141,15 +142,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.Day > DateTime.Now.Day).ToList()); data.Add(select.Where(a => a.Type.Time.Day > DateTime.Now.Day).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Day > DateTime.Now.Day).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (dayofmonth(a.`CreateTime`) > dayofmonth(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (dayofmonth(a__Type.`Time`) > dayofmonth(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (dayofmonth(a__Type__Parent.`Time2`) > dayofmonth(now())) } @@ -159,15 +160,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.DayOfYear > DateTime.Now.DayOfYear).ToList()); data.Add(select.Where(a => a.Type.Time.DayOfYear > DateTime.Now.DayOfYear).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.DayOfYear > DateTime.Now.DayOfYear).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (dayofyear(a.`CreateTime`) > dayofyear(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (dayofyear(a__Type.`Time`) > dayofyear(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (dayofyear(a__Type__Parent.`Time2`) > dayofyear(now())) } @@ -177,15 +178,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.Month > DateTime.Now.Month).ToList()); data.Add(select.Where(a => a.Type.Time.Month > DateTime.Now.Month).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Month > DateTime.Now.Month).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (month(a.`CreateTime`) > month(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (month(a__Type.`Time`) > month(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (month(a__Type__Parent.`Time2`) > month(now())) } @@ -195,15 +196,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.Year > DateTime.Now.Year).ToList()); data.Add(select.Where(a => a.Type.Time.Year > DateTime.Now.Year).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Year > DateTime.Now.Year).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (year(a.`CreateTime`) > year(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (year(a__Type.`Time`) > year(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (year(a__Type__Parent.`Time2`) > year(now())) } @@ -213,15 +214,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.Hour > DateTime.Now.Hour).ToList()); data.Add(select.Where(a => a.Type.Time.Hour > DateTime.Now.Hour).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Hour > DateTime.Now.Hour).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (hour(a.`CreateTime`) > hour(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (hour(a__Type.`Time`) > hour(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (hour(a__Type__Parent.`Time2`) > hour(now())) } @@ -231,15 +232,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.Minute > DateTime.Now.Minute).ToList()); data.Add(select.Where(a => a.Type.Time.Minute > DateTime.Now.Minute).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Minute > DateTime.Now.Minute).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (minute(a.`CreateTime`) > minute(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (minute(a__Type.`Time`) > minute(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (minute(a__Type__Parent.`Time2`) > minute(now())) } @@ -249,15 +250,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.Second > DateTime.Now.Second).ToList()); data.Add(select.Where(a => a.Type.Time.Second > DateTime.Now.Second).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Second > DateTime.Now.Second).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (second(a.`CreateTime`) > second(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (second(a__Type.`Time`) > second(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (second(a__Type__Parent.`Time2`) > second(now())) } @@ -267,15 +268,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.Millisecond > DateTime.Now.Millisecond).ToList()); data.Add(select.Where(a => a.Type.Time.Millisecond > DateTime.Now.Millisecond).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Millisecond > DateTime.Now.Millisecond).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (floor(microsecond(a.`CreateTime`) / 1000) > floor(microsecond(now()) / 1000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (floor(microsecond(a__Type.`Time`) / 1000) > floor(microsecond(now()) / 1000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (floor(microsecond(a__Type__Parent.`Time2`) / 1000) > floor(microsecond(now()) / 1000)) } @@ -285,15 +286,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.Ticks > DateTime.Now.Ticks).ToList()); data.Add(select.Where(a => a.Type.Time.Ticks > DateTime.Now.Ticks).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Ticks > DateTime.Now.Ticks).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((timestampdiff(microsecond, '1970-1-1', a.`CreateTime`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((timestampdiff(microsecond, '1970-1-1', a__Type.`Time`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((timestampdiff(microsecond, '1970-1-1', a__Type__Parent.`Time2`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)) } @@ -303,15 +304,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval ((1 * 86400000000)) microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval ((1 * 86400000000)) microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval ((1 * 86400000000)) microsecond) > now()) } @@ -321,15 +322,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.AddDays(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddDays(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddDays(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) day) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) day) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) day) > now()) } @@ -339,15 +340,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.AddHours(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddHours(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddHours(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) hour) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) hour) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) hour) > now()) } @@ -357,15 +358,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.AddMilliseconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddMilliseconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddMilliseconds(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) * 1000 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) * 1000 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) * 1000 microsecond) > now()) } @@ -375,15 +376,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.AddMinutes(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddMinutes(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddMinutes(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) minute) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) minute) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) minute) > now()) } @@ -393,15 +394,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.AddMonths(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddMonths(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddMonths(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) month) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) month) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) month) > now()) } @@ -411,15 +412,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.AddSeconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddSeconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddSeconds(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) second) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) second) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) second) > now()) } @@ -429,15 +430,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.AddTicks(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddTicks(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddTicks(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) / 10 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) / 10 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) / 10 microsecond) > now()) } @@ -447,15 +448,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.AddYears(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) year) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) year) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) year) > now()) } @@ -465,29 +466,29 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); data.Add(select.Where(a => a.Type.Time.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((timestampdiff(microsecond, now(), a.`CreateTime`)) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((timestampdiff(microsecond, now(), a__Type.`Time`)) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((timestampdiff(microsecond, now(), a__Type__Parent.`Time2`)) / 1000000) > 0); data.Add(select.Where(a => a.CreateTime.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); data.Add(select.Where(a => a.Type.Time.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_sub(a.`CreateTime`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_sub(a__Type.`Time`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_sub(a__Type__Parent.`Time2`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`) } @@ -497,15 +498,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.AddYears(1).Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1).Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).Equals(DateTime.Now)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((date_add(a.`CreateTime`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((date_add(a__Type.`Time`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((date_add(a__Type__Parent.`Time2`, interval (1) year) = now())) } @@ -515,15 +516,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.ToString().Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1).ToString().Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).ToString().Equals(DateTime.Now)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((date_format(a.`CreateTime`, '%Y-%m-%d %H:%i:%s.%f') = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((date_format(date_add(a__Type.`Time`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((date_format(date_add(a__Type__Parent.`Time2`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') = now())) } @@ -534,15 +535,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.CreateTime.CompareTo(DateTime.Now) == 0).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1).CompareTo(DateTime.Now) == 0).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).CompareTo(DateTime.Now) == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((a.`CreateTime`) - (now())) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((date_add(a__Type.`Time`, interval (1) year)) - (now())) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((date_add(a__Type__Parent.`Time2`, interval (1) year)) - (now())) = 0) } @@ -552,15 +553,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => DateTime.DaysInMonth(a.CreateTime.Year, a.CreateTime.Month) > 30).ToList()); data.Add(select.Where(a => DateTime.DaysInMonth(a.Type.Time.Year, a.Type.Time.Month) > 30).ToList()); data.Add(select.Where(a => DateTime.DaysInMonth(a.Type.Parent.Time2.Year, a.Type.Parent.Time2.Month) > 30).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (dayofmonth(last_day(concat(year(a.`CreateTime`), month(a.`CreateTime`), '-01'))) > 30); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (dayofmonth(last_day(concat(year(a__Type.`Time`), month(a__Type.`Time`), '-01'))) > 30); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (dayofmonth(last_day(concat(year(a__Type__Parent.`Time2`), month(a__Type__Parent.`Time2`), '-01'))) > 30) } @@ -570,15 +571,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => DateTime.Equals(a.CreateTime.AddYears(1), DateTime.Now)).ToList()); data.Add(select.Where(a => DateTime.Equals(a.Type.Time.AddYears(1), DateTime.Now)).ToList()); data.Add(select.Where(a => DateTime.Equals(a.Type.Parent.Time2.AddYears(1), DateTime.Now)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((date_add(a.`CreateTime`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((date_add(a__Type.`Time`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((date_add(a__Type__Parent.`Time2`, interval (1) year) = now())) } @@ -588,15 +589,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => DateTime.IsLeapYear(a.CreateTime.Year)).ToList()); data.Add(select.Where(a => DateTime.IsLeapYear(a.Type.Time.AddYears(1).Year)).ToList()); data.Add(select.Where(a => DateTime.IsLeapYear(a.Type.Parent.Time2.AddYears(1).Year)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((year(a.`CreateTime`)) % 4 = 0 AND (year(a.`CreateTime`)) % 100 <> 0 OR (year(a.`CreateTime`)) % 400 = 0)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((year(date_add(a__Type.`Time`, interval (1) year))) % 4 = 0 AND (year(date_add(a__Type.`Time`, interval (1) year))) % 100 <> 0 OR (year(date_add(a__Type.`Time`, interval (1) year))) % 400 = 0)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 4 = 0 AND (year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 100 <> 0 OR (year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 400 = 0)) } @@ -606,15 +607,15 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => DateTime.Parse(a.CreateTime.ToString()) > DateTime.Now).ToList()); data.Add(select.Where(a => DateTime.Parse(a.Type.Time.AddYears(1).ToString()) > DateTime.Now).ToList()); data.Add(select.Where(a => DateTime.Parse(a.Type.Parent.Time2.AddYears(1).ToString()) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (cast(date_format(date_add(a__Type.`Time`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (cast(date_format(date_add(a__Type__Parent.`Time2`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()) } diff --git a/FreeSql.Tests/MySql/MySqlExpression/MathTest.cs b/FreeSql.Tests/MySql/MySqlExpression/MathTest.cs index 4bc5108b..321c9212 100644 --- a/FreeSql.Tests/MySql/MySqlExpression/MathTest.cs +++ b/FreeSql.Tests/MySql/MySqlExpression/MathTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.MySqlExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } diff --git a/FreeSql.Tests/MySql/MySqlExpression/StringTest.cs b/FreeSql.Tests/MySql/MySqlExpression/StringTest.cs index b0331377..b4552933 100644 --- a/FreeSql.Tests/MySql/MySqlExpression/StringTest.cs +++ b/FreeSql.Tests/MySql/MySqlExpression/StringTest.cs @@ -14,12 +14,13 @@ namespace FreeSql.Tests.MySqlExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } } class TestTypeInfo { + [Column(IsIdentity = true)] public int Guid { get; set; } public int ParentId { get; set; } public TestTypeParentInfo Parent { get; set; } @@ -36,7 +37,7 @@ namespace FreeSql.Tests.MySqlExpression { public void Empty() { var data = new List(); data.Add(select.Where(a => (a.Title ?? "") == string.Empty).ToSql()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (ifnull(a.`Title`, '') = '') } @@ -48,38 +49,38 @@ namespace FreeSql.Tests.MySqlExpression { list.Add(select.Where(a => a.Title.StartsWith(a.Title)).ToList()); list.Add(select.Where(a => a.Title.StartsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => a.Title.StartsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE '%aaa') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', a.`Title`)) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', concat(a.`Title`, 1))) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((a.`Title`) LIKE concat('%', a__Type.`Name`)) list.Add(select.Where(a => (a.Title + "aaa").StartsWith("aaa")).ToList()); list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Title)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE '%aaa') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a.`Title`)) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', concat(a.`Title`, 1))) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`)) } @@ -90,38 +91,38 @@ namespace FreeSql.Tests.MySqlExpression { list.Add(select.Where(a => a.Title.EndsWith(a.Title)).ToList()); list.Add(select.Where(a => a.Title.EndsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => a.Title.EndsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE 'aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat(a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat(concat(a.`Title`, 1), '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((a.`Title`) LIKE concat(a__Type.`Name`, '%')) list.Add(select.Where(a => (a.Title + "aaa").EndsWith("aaa")).ToList()); list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Title)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE 'aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat(a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat(concat(a.`Title`, 1), '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((concat(a.`Title`, 'aaa')) LIKE concat(a__Type.`Name`, '%')) } @@ -132,38 +133,38 @@ namespace FreeSql.Tests.MySqlExpression { list.Add(select.Where(a => a.Title.Contains(a.Title)).ToList()); list.Add(select.Where(a => a.Title.Contains(a.Title + 1)).ToList()); list.Add(select.Where(a => a.Title.Contains(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE '%aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', a.`Title` +1, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((a.`Title`) LIKE concat('%', a__Type.`Name`, '%')) list.Add(select.Where(a => (a.Title + "aaa").Contains("aaa")).ToList()); list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title + 1)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE '%aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', concat(a.`Title`, 1), '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`, '%')) } @@ -174,38 +175,38 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.Title.ToLower() == a.Title).ToList()); data.Add(select.Where(a => a.Title.ToLower() == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.ToLower() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(a.`Title`) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE(lower(a.`Title`) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == a.Title).ToList()); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = a__Type.`Name`) } @@ -216,38 +217,38 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.Title.ToUpper() == a.Title).ToList()); data.Add(select.Where(a => a.Title.ToUpper() == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.ToUpper() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(a.`Title`) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (upper(a.`Title`) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == a.Title).ToList()); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = a__Type.`Name`) } @@ -258,38 +259,38 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.Title.Substring(0) == a.Title).ToList()); data.Add(select.Where(a => a.Title.Substring(0) == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.Substring(0) == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(a.`Title`, 1) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(a.`Title`, 1) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(a.`Title`, 1) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (substr(a.`Title`, 1) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(a.Title.Length) == "aaa").ToList()); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(0, a.Title.Length) == a.Title).ToList()); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(0, 3) == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(1, 2) == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), char_length(a.`Title`) + 1) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 1, char_length(a.`Title`)) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 1, 3) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 2, 2) = a__Type.`Name`) } @@ -300,38 +301,38 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.Title.Length == 1).ToList()); data.Add(select.Where(a => a.Title.Length == a.Title.Length + 1).ToList()); data.Add(select.Where(a => a.Title.Length == a.Type.Name.Length).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(a.`Title`) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(a.`Title`) = 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(a.`Title`) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (char_length(a.`Title`) = char_length(a__Type.`Name`)); data.Add(select.Where(a => (a.Title + "aaa").Length == 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").Length == 1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").Length == a.Title.Length + 1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").Length == a.Type.Name.Length).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(concat(a.`Title`, 'aaa')) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(concat(a.`Title`, 'aaa')) = 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(concat(a.`Title`, 'aaa')) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (char_length(concat(a.`Title`, 'aaa')) = char_length(a__Type.`Name`)) } @@ -342,38 +343,38 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == -1).ToList()); data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == (a.Title.Length + 1)).ToList()); data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == a.Type.Name.Length + 1).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(a.`Title`, 'aaa') - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = char_length(a__Type.`Name`) + 1); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa") == -1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == -1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == (a.Title.Length + 1)).ToList()); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == a.Type.Name.Length + 1).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa') - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = char_length(a__Type.`Name`) + 1) } @@ -384,38 +385,38 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(a.`Title`, 10, 'a') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(a.`Title`, 10, 'a') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(a.`Title`, 10, 'a') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (lpad(a.`Title`, 10, 'a') = a__Type.`Name`); data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == "aaa").ToList()); data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a__Type.`Name`) } @@ -426,38 +427,38 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.Title.PadRight(10, 'a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.PadRight(10, 'a') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.PadRight(10, 'a') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(a.`Title`, 10, 'a') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(a.`Title`, 10, 'a') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(a.`Title`, 10, 'a') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (rpad(a.`Title`, 10, 'a') = a__Type.`Name`); data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == "aaa").ToList()); data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a__Type.`Name`) } @@ -468,38 +469,38 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.Title.Trim('a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.Trim('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.Trim('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('a' from a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('b' from trim('a' from a.`Title`)) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim('c' from trim('b' from trim('a' from a.`Title`))) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.Trim() + "aaa").Trim() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.Trim('a') + "aaa").Trim('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.Trim('a', 'b') + "aaa").Trim('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.Trim('a', 'b', 'c') + "aaa").Trim('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(concat(trim(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('a' from concat(trim('a' from a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('b' from trim('a' from concat(trim('b' from trim('a' from a.`Title`)), 'aaa'))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim('c' from trim('b' from trim('a' from concat(trim('c' from trim('b' from trim('a' from a.`Title`))), 'aaa')))) = a__Type.`Name`) } @@ -510,38 +511,38 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.Title.TrimStart('a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.TrimStart('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.TrimStart('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (ltrim(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from trim(leading 'a' from a.`Title`)) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))))) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.TrimStart() + "aaa").TrimStart() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.TrimStart('a') + "aaa").TrimStart('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.TrimStart('a', 'b') + "aaa").TrimStart('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.TrimStart('a', 'b', 'c') + "aaa").TrimStart('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (ltrim(concat(ltrim(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'a' from trim(leading 'a' from a.`Title`)), 'aaa'))) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))), 'aaa'))))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))))), 'aaa'))))))) = a__Type.`Name`) } @@ -552,38 +553,38 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.Title.TrimEnd('a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.TrimEnd('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rtrim(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(trailing 'a' from a.`Title`)) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from a.`Title`))) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.TrimEnd() + "aaa").TrimEnd() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.TrimEnd('a') + "aaa").TrimEnd('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.TrimEnd('a', 'b') + "aaa").TrimEnd('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.TrimEnd('a', 'b', 'c') + "aaa").TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rtrim(concat(rtrim(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from concat(trim(trailing 'a' from a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(trailing 'a' from concat(trim(trailing 'b' from trim(trailing 'a' from a.`Title`)), 'aaa'))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from concat(trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from a.`Title`))), 'aaa')))) = a__Type.`Name`) } @@ -594,38 +595,38 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c") == a.Title).ToList()); data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c").Replace("c", "a") == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c").Replace(a.Type.Name, "a") == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (replace(a.`Title`, 'a', 'b') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (replace(replace(a.`Title`, 'a', 'b'), 'b', 'c') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'c', 'a') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), a__Type.`Name`, 'a') = a__Type.`Name`); data.Add(select.Where(a => (a.Title.Replace("a", "b") + "aaa").TrimEnd() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c") + "aaa").TrimEnd('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c").Replace("c", "a") + "aaa").TrimEnd('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c").Replace(a.Type.Name, "a") + "aaa").TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (concat(replace(a.`Title`, 'a', 'b'), 'aaa') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (concat(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'aaa') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (concat(replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'c', 'a'), 'aaa') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (concat(replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), a__Type.`Name`, 'a'), 'aaa') = a__Type.`Name`) } @@ -636,38 +637,38 @@ namespace FreeSql.Tests.MySqlExpression { data.Add(select.Where(a => a.Title.CompareTo(a.Title) > 0).ToList()); data.Add(select.Where(a => a.Title.CompareTo(a.Title + 1) == 0).ToList()); data.Add(select.Where(a => a.Title.CompareTo(a.Title + a.Type.Name) == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(a.`Title`, a.`Title`) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(a.`Title`, a.`Title`) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(a.`Title`, concat(a.`Title`, 1)) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (strcmp(a.`Title`, concat(a.`Title`, a__Type.`Name`)) = 0); data.Add(select.Where(a => (a.Title + "aaa").CompareTo("aaa") == 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Title) > 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Title + 1) == 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Type.Name) == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(concat(a.`Title`, 'aaa'), 'aaa') = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(concat(a.`Title`, 'aaa'), a.`Title`) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(concat(a.`Title`, 'aaa'), concat(a.`Title`, 1)) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (strcmp(concat(a.`Title`, 'aaa'), a__Type.`Name`) = 0) } diff --git a/FreeSql.Tests/MySql/MySqlExpression/TimeSpanTest.cs b/FreeSql.Tests/MySql/MySqlExpression/TimeSpanTest.cs index 2bf13247..cc96d772 100644 --- a/FreeSql.Tests/MySql/MySqlExpression/TimeSpanTest.cs +++ b/FreeSql.Tests/MySql/MySqlExpression/TimeSpanTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.MySqlExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -35,7 +35,7 @@ namespace FreeSql.Tests.MySqlExpression { public void Zero() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) > 0) } @@ -43,7 +43,7 @@ namespace FreeSql.Tests.MySqlExpression { public void MinValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay > TimeSpan.MinValue).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) > -922337203685477580) } @@ -51,7 +51,7 @@ namespace FreeSql.Tests.MySqlExpression { public void MaxValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay < TimeSpan.MaxValue).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) < 922337203685477580) } @@ -59,7 +59,7 @@ namespace FreeSql.Tests.MySqlExpression { public void Days() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Days == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 86400000000) = 0) } @@ -67,7 +67,7 @@ namespace FreeSql.Tests.MySqlExpression { public void Hours() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Hours > 0).ToSql()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 3600000000) mod 24 > 0) } @@ -75,7 +75,7 @@ namespace FreeSql.Tests.MySqlExpression { public void Milliseconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Milliseconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 1000 mod 1000) > 0) } @@ -83,7 +83,7 @@ namespace FreeSql.Tests.MySqlExpression { public void Minutes() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Minutes > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 60000000 mod 60) > 0) } @@ -91,7 +91,7 @@ namespace FreeSql.Tests.MySqlExpression { public void Seconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Seconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 1000000 mod 60) > 0) } @@ -99,7 +99,7 @@ namespace FreeSql.Tests.MySqlExpression { public void Ticks() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Ticks > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) * 10) > 0) } @@ -107,7 +107,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TotalDays() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalDays > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 86400000000) > 0) } @@ -115,7 +115,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TotalHours() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalHours > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 3600000000) > 0) } @@ -123,7 +123,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TotalMilliseconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalMilliseconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 1000) > 0) } @@ -131,7 +131,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TotalMinutes() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalMinutes > 0).ToSql()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 60000000) > 0) } @@ -139,7 +139,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TotalSeconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalSeconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 1000000) > 0) } @@ -147,7 +147,7 @@ namespace FreeSql.Tests.MySqlExpression { public void Add() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Add(TimeSpan.FromDays(1)) > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) + (1 * 86400000000)) > 0) } @@ -155,7 +155,7 @@ namespace FreeSql.Tests.MySqlExpression { public void Subtract() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Subtract(TimeSpan.FromDays(1)) > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) - (1 * 86400000000)) > 0) } @@ -163,7 +163,7 @@ namespace FreeSql.Tests.MySqlExpression { public void CompareTo() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.CompareTo(TimeSpan.FromDays(1)) > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) - ((1 * 86400000000))) > 0) } @@ -171,7 +171,7 @@ namespace FreeSql.Tests.MySqlExpression { public void this_Equals() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Equals(TimeSpan.FromDays(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) } @@ -179,7 +179,7 @@ namespace FreeSql.Tests.MySqlExpression { public void this_ToString() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.ToString() == "ssss").ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (date_format(date_add(cast('0001/1/1 0:00:00' as datetime), interval (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) microsecond), '%Y-%m-%d %H:%i:%s.%f') = 'ssss') } @@ -188,7 +188,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TimeSpan_Compare() { var data = new List(); data.Add(select.Where(a => TimeSpan.Compare(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1)) > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) - ((1 * 86400000000))) > 0) } @@ -196,7 +196,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TimeSpan_Equals() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) } @@ -204,7 +204,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TimeSpan_FromDays() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) } @@ -212,7 +212,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TimeSpan_FromHours() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromHours(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 3600000000))) } @@ -220,7 +220,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TimeSpan_FromMilliseconds() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromMilliseconds(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 1000))) } @@ -228,7 +228,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TimeSpan_FromMinutes() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromMinutes(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 60000000))) } @@ -236,7 +236,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TimeSpan_FromSeconds() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromSeconds(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 1000000))) } @@ -244,7 +244,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TimeSpan_FromTicks() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromTicks(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 / 10))) } @@ -252,7 +252,7 @@ namespace FreeSql.Tests.MySqlExpression { public void TimeSpan_Parse() { var data = new List(); data.Add(select.Where(a => TimeSpan.Parse(a.CreateTime.TimeOfDay.ToString()) > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (cast(date_format(date_add(cast('0001/1/1 0:00:00' as datetime), interval (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) microsecond), '%Y-%m-%d %H:%i:%s.%f') as signed) > 0) } diff --git a/FreeSql.Tests/Oracle/Curd/OracleSelectTest.cs b/FreeSql.Tests/Oracle/Curd/OracleSelectTest.cs index 8b847983..e32bfbb3 100644 --- a/FreeSql.Tests/Oracle/Curd/OracleSelectTest.cs +++ b/FreeSql.Tests/Oracle/Curd/OracleSelectTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.Oracle { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -35,7 +35,7 @@ namespace FreeSql.Tests.Oracle { class TopicInserts { public Guid Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -81,7 +81,7 @@ namespace FreeSql.Tests.Oracle { var sql2222Tolist = sql2222.ToList(); var collectionSelect = select.Where(a => - a.Type.Guid == a.TestTypeInfoGuid && + a.Type.Guid == a.TypeGuid && a.Type.Parent.Id == a.Type.ParentId && a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any(b => b.ParentId == a.Type.Parent.Id) ); @@ -112,216 +112,216 @@ namespace FreeSql.Tests.Oracle { public void From() { //������� var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id) ); var sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON a.\"TESTTYPEINFOGUID\" = b.\"GUID\" LEFT JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON a.\"TypeGuid\" = b.\"GUID\" LEFT JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql); query2.ToList(); } [Fact] public void LeftJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND a__Type.\"NAME\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\" AND a__Type.\"NAME\" = 'xxx'", sql); query.ToList(); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON 1 = 1 LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND a__Type.\"NAME\" = 'xxx' WHERE (a__Type__Parent.\"ID\" = 10)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON 1 = 1 LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\" AND a__Type.\"NAME\" = 'xxx' WHERE (a__Type__Parent.\"ID\" = 10)", sql); query.ToList(); //���û�е������� - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND b.\"NAME\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TypeGuid\" AND b.\"NAME\" = 'xxx'", sql); query.ToList(); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEPARENTINFO\" b__Parent ON 1 = 1 LEFT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND b.\"NAME\" = 'xxx' WHERE (b__Parent.\"ID\" = 10)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEPARENTINFO\" b__Parent ON 1 = 1 LEFT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TypeGuid\" AND b.\"NAME\" = 'xxx' WHERE (b__Parent.\"ID\" = 10)", sql); query.ToList(); //������� query = select - .LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .LeftJoin(a => a.Type.Guid == a.TypeGuid) .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\" LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\" LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql); query.ToList(); query = select - .LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .LeftJoin((a, b) => b.Guid == a.TypeGuid) .LeftJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\" LEFT JOIN \"TESTTYPEPARENTINFO\" c ON c.\"ID\" = b.\"PARENTID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TypeGuid\" LEFT JOIN \"TESTTYPEPARENTINFO\" c ON c.\"ID\" = b.\"PARENTID\"", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON a.\"TESTTYPEINFOGUID\" = b.\"GUID\" LEFT JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON a.\"TypeGuid\" = b.\"GUID\" LEFT JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql); query2.ToList(); //������϶����㲻�� - query = select.LeftJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\""); + query = select.LeftJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\""); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.LeftJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\" and b.\"NAME\" = :bname", new { bname = "xxx" }); + query = select.LeftJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\" and b.\"NAME\" = :bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\" and b.\"NAME\" = :bname", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\" and b.\"NAME\" = :bname", sql); query.ToList(); } [Fact] public void InnerJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND a__Type.\"NAME\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\" AND a__Type.\"NAME\" = 'xxx'", sql); query.ToList(); - query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON 1 = 1 INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND a__Type.\"NAME\" = 'xxx' WHERE (a__Type__Parent.\"ID\" = 10)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON 1 = 1 INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\" AND a__Type.\"NAME\" = 'xxx' WHERE (a__Type__Parent.\"ID\" = 10)", sql); query.ToList(); //���û�е������� - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND b.\"NAME\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TypeGuid\" AND b.\"NAME\" = 'xxx'", sql); query.ToList(); - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEPARENTINFO\" b__Parent ON 1 = 1 INNER JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND b.\"NAME\" = 'xxx' WHERE (b__Parent.\"ID\" = 10)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEPARENTINFO\" b__Parent ON 1 = 1 INNER JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TypeGuid\" AND b.\"NAME\" = 'xxx' WHERE (b__Parent.\"ID\" = 10)", sql); query.ToList(); //������� query = select - .InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .InnerJoin(a => a.Type.Guid == a.TypeGuid) .InnerJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\" INNER JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\" INNER JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql); query.ToList(); query = select - .InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .InnerJoin((a, b) => b.Guid == a.TypeGuid) .InnerJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\" INNER JOIN \"TESTTYPEPARENTINFO\" c ON c.\"ID\" = b.\"PARENTID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TypeGuid\" INNER JOIN \"TESTTYPEPARENTINFO\" c ON c.\"ID\" = b.\"PARENTID\"", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .InnerJoin(a => a.TestTypeInfoGuid == b.Guid) + .InnerJoin(a => a.TypeGuid == b.Guid) .InnerJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON a.\"TESTTYPEINFOGUID\" = b.\"GUID\" INNER JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON a.\"TypeGuid\" = b.\"GUID\" INNER JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql); query2.ToList(); //������϶����㲻�� - query = select.InnerJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\""); + query = select.InnerJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\""); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.InnerJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\" and b.\"NAME\" = :bname", new { bname = "xxx" }); + query = select.InnerJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\" and b.\"NAME\" = :bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\" and b.\"NAME\" = :bname", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\" and b.\"NAME\" = :bname", sql); query.ToList(); } [Fact] public void RightJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.RightJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.RightJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND a__Type.\"NAME\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\" AND a__Type.\"NAME\" = 'xxx'", sql); query.ToList(); - query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.RightJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON 1 = 1 RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND a__Type.\"NAME\" = 'xxx' WHERE (a__Type__Parent.\"ID\" = 10)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON 1 = 1 RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\" AND a__Type.\"NAME\" = 'xxx' WHERE (a__Type__Parent.\"ID\" = 10)", sql); query.ToList(); //���û�е������� - query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.RightJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.RightJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND b.\"NAME\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TypeGuid\" AND b.\"NAME\" = 'xxx'", sql); query.ToList(); - query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.RightJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEPARENTINFO\" b__Parent ON 1 = 1 RIGHT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND b.\"NAME\" = 'xxx' WHERE (b__Parent.\"ID\" = 10)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEPARENTINFO\" b__Parent ON 1 = 1 RIGHT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TypeGuid\" AND b.\"NAME\" = 'xxx' WHERE (b__Parent.\"ID\" = 10)", sql); query.ToList(); //������� query = select - .RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .RightJoin(a => a.Type.Guid == a.TypeGuid) .RightJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\" RIGHT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\" RIGHT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql); query.ToList(); query = select - .RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .RightJoin((a, b) => b.Guid == a.TypeGuid) .RightJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\" RIGHT JOIN \"TESTTYPEPARENTINFO\" c ON c.\"ID\" = b.\"PARENTID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TypeGuid\" RIGHT JOIN \"TESTTYPEPARENTINFO\" c ON c.\"ID\" = b.\"PARENTID\"", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .RightJoin(a => a.TestTypeInfoGuid == b.Guid) + .RightJoin(a => a.TypeGuid == b.Guid) .RightJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON a.\"TESTTYPEINFOGUID\" = b.\"GUID\" RIGHT JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON a.\"TypeGuid\" = b.\"GUID\" RIGHT JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql); query2.ToList(); //������϶����㲻�� - query = select.RightJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\""); + query = select.RightJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\""); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.RightJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\" and b.\"NAME\" = :bname", new { bname = "xxx" }); + query = select.RightJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\" and b.\"NAME\" = :bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\" and b.\"NAME\" = :bname", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\" and b.\"NAME\" = :bname", sql); query.ToList(); } @@ -330,48 +330,48 @@ namespace FreeSql.Tests.Oracle { //����е�������a.Type��a.Type.Parent ���ǵ������� var query = select.Where(a => a.Id == 10); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"ID\" = 10)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"ID\" = 10)", sql); query.ToList(); query = select.Where(a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"ID\" = 10 AND a.\"ID\" > 10 OR a.\"CLICKS\" > 100)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"ID\" = 10 AND a.\"ID\" > 10 OR a.\"CLICKS\" > 100)", sql); query.ToList(); query = select.Where(a => a.Id == 10).Where(a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"ID\" = 10) AND (a.\"CLICKS\" > 100)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"ID\" = 10) AND (a.\"CLICKS\" > 100)", sql); query.ToList(); query = select.Where(a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" a__Type WHERE (a__Type.\"NAME\" = 'typeTitle')", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" a__Type WHERE (a__Type.\"NAME\" = 'typeTitle')", sql); query.ToList(); - query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" a__Type WHERE (a__Type.\"NAME\" = 'typeTitle' AND a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\")", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" a__Type WHERE (a__Type.\"NAME\" = 'typeTitle' AND a__Type.\"GUID\" = a.\"TypeGuid\")", sql); query.ToList(); query = select.Where(a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" a__Type, \"TESTTYPEPARENTINFO\" a__Type__Parent WHERE (a__Type__Parent.\"NAME\" = 'tparent')", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" a__Type, \"TESTTYPEPARENTINFO\" a__Type__Parent WHERE (a__Type__Parent.\"NAME\" = 'tparent')", sql); query.ToList(); //���û�е������ԣ��򵥶������ - query = select.Where((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "typeTitle"); + query = select.Where((a, b) => b.Guid == a.TypeGuid && b.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" b WHERE (b.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND b.\"NAME\" = 'typeTitle')", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" b WHERE (b.\"GUID\" = a.\"TypeGuid\" AND b.\"NAME\" = 'typeTitle')", sql); query.ToList(); - query = select.Where((a, b) => b.Name == "typeTitle" && b.Guid == a.TestTypeInfoGuid); + query = select.Where((a, b) => b.Name == "typeTitle" && b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" b WHERE (b.\"NAME\" = 'typeTitle' AND b.\"GUID\" = a.\"TESTTYPEINFOGUID\")", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" b WHERE (b.\"NAME\" = 'typeTitle' AND b.\"GUID\" = a.\"TypeGuid\")", sql); query.ToList(); query = select.Where((a, b, c) => c.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEPARENTINFO\" c WHERE (c.\"NAME\" = 'tparent')", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEPARENTINFO\" c WHERE (c.\"NAME\" = 'tparent')", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -379,13 +379,13 @@ namespace FreeSql.Tests.Oracle { .Where(a => a.Id == 10 && c.Name == "xxx") .Where(a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEPARENTINFO\" c, \"TESTTYPEINFO\" b WHERE (a.\"ID\" = 10 AND c.\"NAME\" = 'xxx') AND (b.\"PARENTID\" = 20)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEPARENTINFO\" c, \"TESTTYPEINFO\" b WHERE (a.\"ID\" = 10 AND c.\"NAME\" = 'xxx') AND (b.\"PARENTID\" = 20)", sql); query2.ToList(); //������϶����㲻�� query = select.Where("a.\"CLICKS\" > 100 and a.\"ID\" = :id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"CLICKS\" > 100 and a.\"ID\" = :id)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"CLICKS\" > 100 and a.\"ID\" = :id)", sql); query.ToList(); } [Fact] @@ -393,32 +393,32 @@ namespace FreeSql.Tests.Oracle { //����е�������a.Type��a.Type.Parent ���ǵ������� var query = select.WhereIf(true, a => a.Id == 10); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"ID\" = 10)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"ID\" = 10)", sql); query.ToList(); query = select.WhereIf(true, a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"ID\" = 10 AND a.\"ID\" > 10 OR a.\"CLICKS\" > 100)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"ID\" = 10 AND a.\"ID\" > 10 OR a.\"CLICKS\" > 100)", sql); query.ToList(); query = select.WhereIf(true, a => a.Id == 10).WhereIf(true, a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"ID\" = 10) AND (a.\"CLICKS\" > 100)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"ID\" = 10) AND (a.\"CLICKS\" > 100)", sql); query.ToList(); query = select.WhereIf(true, a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" a__Type WHERE (a__Type.\"NAME\" = 'typeTitle')", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" a__Type WHERE (a__Type.\"NAME\" = 'typeTitle')", sql); query.ToList(); - query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" a__Type WHERE (a__Type.\"NAME\" = 'typeTitle' AND a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\")", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" a__Type WHERE (a__Type.\"NAME\" = 'typeTitle' AND a__Type.\"GUID\" = a.\"TypeGuid\")", sql); query.ToList(); query = select.WhereIf(true, a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" a__Type, \"TESTTYPEPARENTINFO\" a__Type__Parent WHERE (a__Type__Parent.\"NAME\" = 'tparent')", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" a__Type, \"TESTTYPEPARENTINFO\" a__Type__Parent WHERE (a__Type__Parent.\"NAME\" = 'tparent')", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -426,13 +426,13 @@ namespace FreeSql.Tests.Oracle { .WhereIf(true, a => a.Id == 10 && c.Name == "xxx") .WhereIf(true, a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEPARENTINFO\" c, \"TESTTYPEINFO\" b WHERE (a.\"ID\" = 10 AND c.\"NAME\" = 'xxx') AND (b.\"PARENTID\" = 20)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEPARENTINFO\" c, \"TESTTYPEINFO\" b WHERE (a.\"ID\" = 10 AND c.\"NAME\" = 'xxx') AND (b.\"PARENTID\" = 20)", sql); query2.ToList(); //������϶����㲻�� query = select.WhereIf(true, "a.\"CLICKS\" > 100 and a.\"ID\" = :id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"CLICKS\" > 100 and a.\"ID\" = :id)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"CLICKS\" > 100 and a.\"ID\" = :id)", sql); query.ToList(); // ==========================================WhereIf(false) @@ -440,32 +440,32 @@ namespace FreeSql.Tests.Oracle { //����е�������a.Type��a.Type.Parent ���ǵ������� query = select.WhereIf(false, a => a.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); query.ToList(); query = select.WhereIf(false, a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); query.ToList(); query = select.WhereIf(false, a => a.Id == 10).WhereIf(false, a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); query.ToList(); query = select.WhereIf(false, a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); query.ToList(); - query = select.WhereIf(false, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.WhereIf(false, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); query.ToList(); query = select.WhereIf(false, a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -473,13 +473,13 @@ namespace FreeSql.Tests.Oracle { .WhereIf(false, a => a.Id == 10 && c.Name == "xxx") .WhereIf(false, a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); query2.ToList(); //������϶����㲻�� query = select.WhereIf(false, "a.\"CLICKS\" > 100 and a.\"ID\" = :id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); query.ToList(); } [Fact] @@ -554,59 +554,59 @@ namespace FreeSql.Tests.Oracle { }; //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid).AsTable(tableRule); + var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).AsTable(tableRule); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\"", sql); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").AsTable(tableRule); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND a__Type.\"NAME\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\" AND a__Type.\"NAME\" = 'xxx'", sql); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEPARENTINFOAsTable\" a__Type__Parent ON 1 = 1 LEFT JOIN \"TESTTYPEINFOAsTable2\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND a__Type.\"NAME\" = 'xxx' WHERE (a__Type__Parent.\"ID\" = 10)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEPARENTINFOAsTable\" a__Type__Parent ON 1 = 1 LEFT JOIN \"TESTTYPEINFOAsTable2\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\" AND a__Type.\"NAME\" = 'xxx' WHERE (a__Type__Parent.\"ID\" = 10)", sql); //���û�е������� - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid).AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" b ON b.\"GUID\" = a.\"TypeGuid\"", sql); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND b.\"NAME\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" b ON b.\"GUID\" = a.\"TypeGuid\" AND b.\"NAME\" = 'xxx'", sql); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEPARENTINFOAsTable\" b__Parent ON 1 = 1 LEFT JOIN \"TESTTYPEINFOAsTable2\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\" AND b.\"NAME\" = 'xxx' WHERE (b__Parent.\"ID\" = 10)", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEPARENTINFOAsTable\" b__Parent ON 1 = 1 LEFT JOIN \"TESTTYPEINFOAsTable2\" b ON b.\"GUID\" = a.\"TypeGuid\" AND b.\"NAME\" = 'xxx' WHERE (b__Parent.\"ID\" = 10)", sql); //������� query = select - .LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .LeftJoin(a => a.Type.Guid == a.TypeGuid) .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" a__Type ON a__Type.\"GUID\" = a.\"TESTTYPEINFOGUID\" LEFT JOIN \"TESTTYPEPARENTINFOAsTable\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" a__Type ON a__Type.\"GUID\" = a.\"TypeGuid\" LEFT JOIN \"TESTTYPEPARENTINFOAsTable\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql); query = select - .LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .LeftJoin((a, b) => b.Guid == a.TypeGuid) .LeftJoin((a, c) => c.Id == a.Type.ParentId).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" b ON b.\"GUID\" = a.\"TESTTYPEINFOGUID\" LEFT JOIN \"TESTTYPEPARENTINFOAsTable\" c ON c.\"ID\" = b.\"PARENTID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" b ON b.\"GUID\" = a.\"TypeGuid\" LEFT JOIN \"TESTTYPEPARENTINFOAsTable\" c ON c.\"ID\" = b.\"PARENTID\"", sql); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id)).AsTable(tableRule); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" b ON a.\"TESTTYPEINFOGUID\" = b.\"GUID\" LEFT JOIN \"TESTTYPEPARENTINFOAsTable\" c ON b.\"PARENTID\" = c.\"ID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFOAsTable2\" b ON a.\"TypeGuid\" = b.\"GUID\" LEFT JOIN \"TESTTYPEPARENTINFOAsTable\" c ON b.\"PARENTID\" = c.\"ID\"", sql); //������϶����㲻�� - query = select.LeftJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\"").AsTable(tableRule); + query = select.LeftJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\"").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\"", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\"", sql); - query = select.LeftJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\" and b.\"NAME\" = :bname", new { bname = "xxx" }).AsTable(tableRule); + query = select.LeftJoin("\"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\" and b.\"NAME\" = :bname", new { bname = "xxx" }).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TESTTYPEINFOGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TESTTYPEINFOGUID\" and b.\"NAME\" = :bname", sql); + Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TypeGuid\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22AsTable1\" a LEFT JOIN \"TESTTYPEINFO\" b on b.\"GUID\" = a.\"TypeGuid\" and b.\"NAME\" = :bname", sql); } } } diff --git a/FreeSql.Tests/Oracle/OracleExpression/ConvertTest.cs b/FreeSql.Tests/Oracle/OracleExpression/ConvertTest.cs index d2109189..6a25445b 100644 --- a/FreeSql.Tests/Oracle/OracleExpression/ConvertTest.cs +++ b/FreeSql.Tests/Oracle/OracleExpression/ConvertTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.OracleExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -36,7 +36,7 @@ namespace FreeSql.Tests.OracleExpression { public void ToBoolean() { //var data = new List(); //data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 2) > 0).ToList()); - //SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` + //SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` //FROM `tb_topic` a //WHERE ((a.`Clicks` not in ('0','false'))) } diff --git a/FreeSql.Tests/Oracle/OracleExpression/DateTimeTest.cs b/FreeSql.Tests/Oracle/OracleExpression/DateTimeTest.cs index ee54bc90..760f7cd1 100644 --- a/FreeSql.Tests/Oracle/OracleExpression/DateTimeTest.cs +++ b/FreeSql.Tests/Oracle/OracleExpression/DateTimeTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.OracleExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -39,7 +39,7 @@ namespace FreeSql.Tests.OracleExpression { public void Now() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.Now.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(now(), '%Y-%m-%d') as datetime)) } @@ -47,7 +47,7 @@ namespace FreeSql.Tests.OracleExpression { public void UtcNow() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.UtcNow.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(utc_timestamp(), '%Y-%m-%d') as datetime)) } @@ -55,7 +55,7 @@ namespace FreeSql.Tests.OracleExpression { public void MinValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.MinValue.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(cast('0001/1/1 0:00:00' as datetime), '%Y-%m-%d') as datetime)) } @@ -63,7 +63,7 @@ namespace FreeSql.Tests.OracleExpression { public void MaxValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.MaxValue.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(cast('9999/12/31 23:59:59' as datetime), '%Y-%m-%d') as datetime)) } @@ -73,29 +73,29 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.Date == DateTime.Now.Date).ToList()); data.Add(select.Where(a => a.Type.Time.Date > DateTime.Now.Date).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Date > DateTime.Now.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(now(), '%Y-%m-%d') as datetime)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (cast(date_format(a__Type.`Time`, '%Y-%m-%d') as datetime) > cast(date_format(now(), '%Y-%m-%d') as datetime)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (cast(date_format(a__Type__Parent.`Time2`, '%Y-%m-%d') as datetime) > cast(date_format(now(), '%Y-%m-%d') as datetime)); data.Add(select.Where(a => DateTime.Now.Subtract(a.CreateTime.Date).TotalSeconds > 0).ToList()); data.Add(select.Where(a => DateTime.Now.Subtract(a.Type.Time.Date).TotalSeconds > 0).ToList()); data.Add(select.Where(a => DateTime.Now.Subtract(a.Type.Parent.Time2.Date).TotalSeconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((timestampdiff(microsecond, cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((timestampdiff(microsecond, cast(date_format(a__Type.`Time`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((timestampdiff(microsecond, cast(date_format(a__Type__Parent.`Time2`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0) } @@ -105,15 +105,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.TimeOfDay == DateTime.Now.TimeOfDay).ToList()); data.Add(select.Where(a => a.Type.Time.TimeOfDay > DateTime.Now.TimeOfDay).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.TimeOfDay > DateTime.Now.TimeOfDay).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((timestampdiff(microsecond, date_format(a__Type.`Time`, '1970-1-1 %H:%i:%s.%f'), a__Type.`Time`) + 62135596800000000) > (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((timestampdiff(microsecond, date_format(a__Type__Parent.`Time2`, '1970-1-1 %H:%i:%s.%f'), a__Type__Parent.`Time2`) + 62135596800000000) > (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)) } @@ -123,15 +123,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); data.Add(select.Where(a => a.Type.Time.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((dayofweek(a.`CreateTime`) - 1) > (dayofweek(now()) - 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((dayofweek(a__Type.`Time`) - 1) > (dayofweek(now()) - 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((dayofweek(a__Type__Parent.`Time2`) - 1) > (dayofweek(now()) - 1)) } @@ -141,15 +141,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.Day > DateTime.Now.Day).ToList()); data.Add(select.Where(a => a.Type.Time.Day > DateTime.Now.Day).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Day > DateTime.Now.Day).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (dayofmonth(a.`CreateTime`) > dayofmonth(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (dayofmonth(a__Type.`Time`) > dayofmonth(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (dayofmonth(a__Type__Parent.`Time2`) > dayofmonth(now())) } @@ -159,15 +159,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.DayOfYear > DateTime.Now.DayOfYear).ToList()); data.Add(select.Where(a => a.Type.Time.DayOfYear > DateTime.Now.DayOfYear).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.DayOfYear > DateTime.Now.DayOfYear).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (dayofyear(a.`CreateTime`) > dayofyear(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (dayofyear(a__Type.`Time`) > dayofyear(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (dayofyear(a__Type__Parent.`Time2`) > dayofyear(now())) } @@ -177,15 +177,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.Month > DateTime.Now.Month).ToList()); data.Add(select.Where(a => a.Type.Time.Month > DateTime.Now.Month).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Month > DateTime.Now.Month).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (month(a.`CreateTime`) > month(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (month(a__Type.`Time`) > month(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (month(a__Type__Parent.`Time2`) > month(now())) } @@ -195,15 +195,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.Year > DateTime.Now.Year).ToList()); data.Add(select.Where(a => a.Type.Time.Year > DateTime.Now.Year).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Year > DateTime.Now.Year).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (year(a.`CreateTime`) > year(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (year(a__Type.`Time`) > year(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (year(a__Type__Parent.`Time2`) > year(now())) } @@ -213,15 +213,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.Hour > DateTime.Now.Hour).ToList()); data.Add(select.Where(a => a.Type.Time.Hour > DateTime.Now.Hour).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Hour > DateTime.Now.Hour).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (hour(a.`CreateTime`) > hour(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (hour(a__Type.`Time`) > hour(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (hour(a__Type__Parent.`Time2`) > hour(now())) } @@ -231,15 +231,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.Minute > DateTime.Now.Minute).ToList()); data.Add(select.Where(a => a.Type.Time.Minute > DateTime.Now.Minute).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Minute > DateTime.Now.Minute).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (minute(a.`CreateTime`) > minute(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (minute(a__Type.`Time`) > minute(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (minute(a__Type__Parent.`Time2`) > minute(now())) } @@ -249,15 +249,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.Second > DateTime.Now.Second).ToList()); data.Add(select.Where(a => a.Type.Time.Second > DateTime.Now.Second).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Second > DateTime.Now.Second).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (second(a.`CreateTime`) > second(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (second(a__Type.`Time`) > second(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (second(a__Type__Parent.`Time2`) > second(now())) } @@ -267,15 +267,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.Millisecond > DateTime.Now.Millisecond).ToList()); data.Add(select.Where(a => a.Type.Time.Millisecond > DateTime.Now.Millisecond).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Millisecond > DateTime.Now.Millisecond).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (floor(microsecond(a.`CreateTime`) / 1000) > floor(microsecond(now()) / 1000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (floor(microsecond(a__Type.`Time`) / 1000) > floor(microsecond(now()) / 1000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (floor(microsecond(a__Type__Parent.`Time2`) / 1000) > floor(microsecond(now()) / 1000)) } @@ -285,15 +285,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.Ticks > DateTime.Now.Ticks).ToList()); data.Add(select.Where(a => a.Type.Time.Ticks > DateTime.Now.Ticks).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Ticks > DateTime.Now.Ticks).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((timestampdiff(microsecond, '1970-1-1', a.`CreateTime`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((timestampdiff(microsecond, '1970-1-1', a__Type.`Time`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((timestampdiff(microsecond, '1970-1-1', a__Type__Parent.`Time2`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)) } @@ -303,15 +303,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval ((1 * 86400000000)) microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval ((1 * 86400000000)) microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval ((1 * 86400000000)) microsecond) > now()) } @@ -321,15 +321,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.AddDays(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddDays(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddDays(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) day) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) day) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) day) > now()) } @@ -339,15 +339,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.AddHours(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddHours(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddHours(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) hour) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) hour) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) hour) > now()) } @@ -357,15 +357,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.AddMilliseconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddMilliseconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddMilliseconds(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) * 1000 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) * 1000 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) * 1000 microsecond) > now()) } @@ -375,15 +375,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.AddMinutes(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddMinutes(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddMinutes(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) minute) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) minute) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) minute) > now()) } @@ -393,15 +393,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.AddMonths(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddMonths(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddMonths(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) month) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) month) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) month) > now()) } @@ -411,15 +411,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.AddSeconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddSeconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddSeconds(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) second) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) second) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) second) > now()) } @@ -429,15 +429,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.AddTicks(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddTicks(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddTicks(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) / 10 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) / 10 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) / 10 microsecond) > now()) } @@ -447,15 +447,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.AddYears(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) year) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) year) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) year) > now()) } @@ -465,29 +465,29 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); data.Add(select.Where(a => a.Type.Time.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((timestampdiff(microsecond, now(), a.`CreateTime`)) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((timestampdiff(microsecond, now(), a__Type.`Time`)) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((timestampdiff(microsecond, now(), a__Type__Parent.`Time2`)) / 1000000) > 0); data.Add(select.Where(a => a.CreateTime.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); data.Add(select.Where(a => a.Type.Time.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_sub(a.`CreateTime`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_sub(a__Type.`Time`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_sub(a__Type__Parent.`Time2`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`) } @@ -497,15 +497,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.AddYears(1).Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1).Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).Equals(DateTime.Now)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((date_add(a.`CreateTime`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((date_add(a__Type.`Time`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((date_add(a__Type__Parent.`Time2`, interval (1) year) = now())) } @@ -515,15 +515,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.ToString().Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1).ToString().Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).ToString().Equals(DateTime.Now)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((date_format(a.`CreateTime`, '%Y-%m-%d %H:%i:%s.%f') = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((date_format(date_add(a__Type.`Time`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((date_format(date_add(a__Type__Parent.`Time2`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') = now())) } @@ -534,15 +534,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.CreateTime.CompareTo(DateTime.Now) == 0).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1).CompareTo(DateTime.Now) == 0).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).CompareTo(DateTime.Now) == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((a.`CreateTime`) - (now())) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((date_add(a__Type.`Time`, interval (1) year)) - (now())) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((date_add(a__Type__Parent.`Time2`, interval (1) year)) - (now())) = 0) } @@ -552,15 +552,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => DateTime.DaysInMonth(a.CreateTime.Year, a.CreateTime.Month) > 30).ToList()); data.Add(select.Where(a => DateTime.DaysInMonth(a.Type.Time.Year, a.Type.Time.Month) > 30).ToList()); data.Add(select.Where(a => DateTime.DaysInMonth(a.Type.Parent.Time2.Year, a.Type.Parent.Time2.Month) > 30).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (dayofmonth(last_day(concat(year(a.`CreateTime`), month(a.`CreateTime`), '-01'))) > 30); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (dayofmonth(last_day(concat(year(a__Type.`Time`), month(a__Type.`Time`), '-01'))) > 30); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (dayofmonth(last_day(concat(year(a__Type__Parent.`Time2`), month(a__Type__Parent.`Time2`), '-01'))) > 30) } @@ -570,15 +570,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => DateTime.Equals(a.CreateTime.AddYears(1), DateTime.Now)).ToList()); data.Add(select.Where(a => DateTime.Equals(a.Type.Time.AddYears(1), DateTime.Now)).ToList()); data.Add(select.Where(a => DateTime.Equals(a.Type.Parent.Time2.AddYears(1), DateTime.Now)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((date_add(a.`CreateTime`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((date_add(a__Type.`Time`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((date_add(a__Type__Parent.`Time2`, interval (1) year) = now())) } @@ -588,15 +588,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => DateTime.IsLeapYear(a.CreateTime.Year)).ToList()); data.Add(select.Where(a => DateTime.IsLeapYear(a.Type.Time.AddYears(1).Year)).ToList()); data.Add(select.Where(a => DateTime.IsLeapYear(a.Type.Parent.Time2.AddYears(1).Year)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((year(a.`CreateTime`)) % 4 = 0 AND (year(a.`CreateTime`)) % 100 <> 0 OR (year(a.`CreateTime`)) % 400 = 0)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((year(date_add(a__Type.`Time`, interval (1) year))) % 4 = 0 AND (year(date_add(a__Type.`Time`, interval (1) year))) % 100 <> 0 OR (year(date_add(a__Type.`Time`, interval (1) year))) % 400 = 0)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 4 = 0 AND (year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 100 <> 0 OR (year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 400 = 0)) } @@ -606,15 +606,15 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => DateTime.Parse(a.CreateTime.ToString()) > DateTime.Now).ToList()); data.Add(select.Where(a => DateTime.Parse(a.Type.Time.AddYears(1).ToString()) > DateTime.Now).ToList()); data.Add(select.Where(a => DateTime.Parse(a.Type.Parent.Time2.AddYears(1).ToString()) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (cast(date_format(date_add(a__Type.`Time`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (cast(date_format(date_add(a__Type__Parent.`Time2`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()) } diff --git a/FreeSql.Tests/Oracle/OracleExpression/MathTest.cs b/FreeSql.Tests/Oracle/OracleExpression/MathTest.cs index 7131656f..51bd9fb1 100644 --- a/FreeSql.Tests/Oracle/OracleExpression/MathTest.cs +++ b/FreeSql.Tests/Oracle/OracleExpression/MathTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.OracleExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } diff --git a/FreeSql.Tests/Oracle/OracleExpression/StringTest.cs b/FreeSql.Tests/Oracle/OracleExpression/StringTest.cs index 3d74e272..b9def53c 100644 --- a/FreeSql.Tests/Oracle/OracleExpression/StringTest.cs +++ b/FreeSql.Tests/Oracle/OracleExpression/StringTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.OracleExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -36,7 +36,7 @@ namespace FreeSql.Tests.OracleExpression { public void Empty() { var data = new List(); data.Add(select.Where(a => (a.Title ?? "") == string.Empty).ToSql()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (ifnull(a.`Title`, '') = '') } @@ -48,38 +48,38 @@ namespace FreeSql.Tests.OracleExpression { list.Add(select.Where(a => a.Title.StartsWith(a.Title)).ToList()); list.Add(select.Where(a => a.Title.StartsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => a.Title.StartsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE '%aaa') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', a.`Title`)) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', concat(a.`Title`, 1))) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((a.`Title`) LIKE concat('%', a__Type.`Name`)) list.Add(select.Where(a => (a.Title + "aaa").StartsWith("aaa")).ToList()); list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Title)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE '%aaa') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a.`Title`)) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', concat(a.`Title`, 1))) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`)) } @@ -90,38 +90,38 @@ namespace FreeSql.Tests.OracleExpression { list.Add(select.Where(a => a.Title.EndsWith(a.Title)).ToList()); list.Add(select.Where(a => a.Title.EndsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => a.Title.EndsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE 'aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat(a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat(concat(a.`Title`, 1), '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((a.`Title`) LIKE concat(a__Type.`Name`, '%')) list.Add(select.Where(a => (a.Title + "aaa").EndsWith("aaa")).ToList()); list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Title)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE 'aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat(a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat(concat(a.`Title`, 1), '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((concat(a.`Title`, 'aaa')) LIKE concat(a__Type.`Name`, '%')) } @@ -132,38 +132,38 @@ namespace FreeSql.Tests.OracleExpression { list.Add(select.Where(a => a.Title.Contains(a.Title)).ToList()); list.Add(select.Where(a => a.Title.Contains(a.Title + 1)).ToList()); list.Add(select.Where(a => a.Title.Contains(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE '%aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', a.`Title` +1, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((a.`Title`) LIKE concat('%', a__Type.`Name`, '%')) list.Add(select.Where(a => (a.Title + "aaa").Contains("aaa")).ToList()); list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title + 1)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE '%aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', concat(a.`Title`, 1), '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`, '%')) } @@ -174,38 +174,38 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.Title.ToLower() == a.Title).ToList()); data.Add(select.Where(a => a.Title.ToLower() == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.ToLower() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(a.`Title`) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE(lower(a.`Title`) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == a.Title).ToList()); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = a__Type.`Name`) } @@ -216,38 +216,38 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.Title.ToUpper() == a.Title).ToList()); data.Add(select.Where(a => a.Title.ToUpper() == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.ToUpper() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(a.`Title`) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (upper(a.`Title`) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == a.Title).ToList()); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = a__Type.`Name`) } @@ -258,38 +258,38 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.Title.Substring(0) == a.Title).ToList()); data.Add(select.Where(a => a.Title.Substring(0) == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.Substring(0) == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(a.`Title`, 1) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(a.`Title`, 1) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(a.`Title`, 1) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (substr(a.`Title`, 1) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(a.Title.Length) == "aaa").ToList()); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(0, a.Title.Length) == a.Title).ToList()); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(0, 3) == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(1, 2) == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), char_length(a.`Title`) + 1) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 1, char_length(a.`Title`)) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 1, 3) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 2, 2) = a__Type.`Name`) } @@ -300,38 +300,38 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.Title.Length == 1).ToList()); data.Add(select.Where(a => a.Title.Length == a.Title.Length + 1).ToList()); data.Add(select.Where(a => a.Title.Length == a.Type.Name.Length).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(a.`Title`) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(a.`Title`) = 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(a.`Title`) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (char_length(a.`Title`) = char_length(a__Type.`Name`)); data.Add(select.Where(a => (a.Title + "aaa").Length == 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").Length == 1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").Length == a.Title.Length + 1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").Length == a.Type.Name.Length).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(concat(a.`Title`, 'aaa')) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(concat(a.`Title`, 'aaa')) = 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(concat(a.`Title`, 'aaa')) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (char_length(concat(a.`Title`, 'aaa')) = char_length(a__Type.`Name`)) } @@ -342,38 +342,38 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == -1).ToList()); data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == (a.Title.Length + 1)).ToList()); data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == a.Type.Name.Length + 1).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(a.`Title`, 'aaa') - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = char_length(a__Type.`Name`) + 1); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa") == -1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == -1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == (a.Title.Length + 1)).ToList()); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == a.Type.Name.Length + 1).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa') - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = char_length(a__Type.`Name`) + 1) } @@ -384,38 +384,38 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(a.`Title`, 10, 'a') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(a.`Title`, 10, 'a') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(a.`Title`, 10, 'a') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (lpad(a.`Title`, 10, 'a') = a__Type.`Name`); data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == "aaa").ToList()); data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a__Type.`Name`) } @@ -426,38 +426,38 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.Title.PadRight(10, 'a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.PadRight(10, 'a') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.PadRight(10, 'a') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(a.`Title`, 10, 'a') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(a.`Title`, 10, 'a') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(a.`Title`, 10, 'a') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (rpad(a.`Title`, 10, 'a') = a__Type.`Name`); data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == "aaa").ToList()); data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a__Type.`Name`) } @@ -468,38 +468,38 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.Title.Trim('a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.Trim('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.Trim('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('a' from a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('b' from trim('a' from a.`Title`)) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim('c' from trim('b' from trim('a' from a.`Title`))) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.Trim() + "aaa").Trim() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.Trim('a') + "aaa").Trim('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.Trim('a', 'b') + "aaa").Trim('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.Trim('a', 'b', 'c') + "aaa").Trim('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(concat(trim(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('a' from concat(trim('a' from a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('b' from trim('a' from concat(trim('b' from trim('a' from a.`Title`)), 'aaa'))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim('c' from trim('b' from trim('a' from concat(trim('c' from trim('b' from trim('a' from a.`Title`))), 'aaa')))) = a__Type.`Name`) } @@ -510,38 +510,38 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.Title.TrimStart('a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.TrimStart('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.TrimStart('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (ltrim(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from trim(leading 'a' from a.`Title`)) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))))) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.TrimStart() + "aaa").TrimStart() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.TrimStart('a') + "aaa").TrimStart('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.TrimStart('a', 'b') + "aaa").TrimStart('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.TrimStart('a', 'b', 'c') + "aaa").TrimStart('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (ltrim(concat(ltrim(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'a' from trim(leading 'a' from a.`Title`)), 'aaa'))) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))), 'aaa'))))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))))), 'aaa'))))))) = a__Type.`Name`) } @@ -552,38 +552,38 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.Title.TrimEnd('a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.TrimEnd('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rtrim(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(trailing 'a' from a.`Title`)) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from a.`Title`))) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.TrimEnd() + "aaa").TrimEnd() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.TrimEnd('a') + "aaa").TrimEnd('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.TrimEnd('a', 'b') + "aaa").TrimEnd('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.TrimEnd('a', 'b', 'c') + "aaa").TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rtrim(concat(rtrim(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from concat(trim(trailing 'a' from a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(trailing 'a' from concat(trim(trailing 'b' from trim(trailing 'a' from a.`Title`)), 'aaa'))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from concat(trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from a.`Title`))), 'aaa')))) = a__Type.`Name`) } @@ -594,38 +594,38 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c") == a.Title).ToList()); data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c").Replace("c", "a") == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c").Replace(a.Type.Name, "a") == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (replace(a.`Title`, 'a', 'b') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (replace(replace(a.`Title`, 'a', 'b'), 'b', 'c') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'c', 'a') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), a__Type.`Name`, 'a') = a__Type.`Name`); data.Add(select.Where(a => (a.Title.Replace("a", "b") + "aaa").TrimEnd() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c") + "aaa").TrimEnd('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c").Replace("c", "a") + "aaa").TrimEnd('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c").Replace(a.Type.Name, "a") + "aaa").TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (concat(replace(a.`Title`, 'a', 'b'), 'aaa') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (concat(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'aaa') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (concat(replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'c', 'a'), 'aaa') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (concat(replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), a__Type.`Name`, 'a'), 'aaa') = a__Type.`Name`) } @@ -636,38 +636,38 @@ namespace FreeSql.Tests.OracleExpression { data.Add(select.Where(a => a.Title.CompareTo(a.Title) > 0).ToList()); data.Add(select.Where(a => a.Title.CompareTo(a.Title + 1) == 0).ToList()); data.Add(select.Where(a => a.Title.CompareTo(a.Title + a.Type.Name) == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(a.`Title`, a.`Title`) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(a.`Title`, a.`Title`) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(a.`Title`, concat(a.`Title`, 1)) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (strcmp(a.`Title`, concat(a.`Title`, a__Type.`Name`)) = 0); data.Add(select.Where(a => (a.Title + "aaa").CompareTo("aaa") == 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Title) > 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Title + 1) == 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Type.Name) == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(concat(a.`Title`, 'aaa'), 'aaa') = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(concat(a.`Title`, 'aaa'), a.`Title`) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(concat(a.`Title`, 'aaa'), concat(a.`Title`, 1)) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (strcmp(concat(a.`Title`, 'aaa'), a__Type.`Name`) = 0) } diff --git a/FreeSql.Tests/Oracle/OracleExpression/TimeSpanTest.cs b/FreeSql.Tests/Oracle/OracleExpression/TimeSpanTest.cs index 0df64f73..00e5491e 100644 --- a/FreeSql.Tests/Oracle/OracleExpression/TimeSpanTest.cs +++ b/FreeSql.Tests/Oracle/OracleExpression/TimeSpanTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.OracleExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -35,7 +35,7 @@ namespace FreeSql.Tests.OracleExpression { public void Zero() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) > 0) } @@ -43,7 +43,7 @@ namespace FreeSql.Tests.OracleExpression { public void MinValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay > TimeSpan.MinValue).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) > -922337203685477580) } @@ -51,7 +51,7 @@ namespace FreeSql.Tests.OracleExpression { public void MaxValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay < TimeSpan.MaxValue).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) < 922337203685477580) } @@ -59,7 +59,7 @@ namespace FreeSql.Tests.OracleExpression { public void Days() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Days == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 86400000000) = 0) } @@ -67,7 +67,7 @@ namespace FreeSql.Tests.OracleExpression { public void Hours() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Hours > 0).ToSql()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 3600000000) mod 24 > 0) } @@ -75,7 +75,7 @@ namespace FreeSql.Tests.OracleExpression { public void Milliseconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Milliseconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 1000 mod 1000) > 0) } @@ -83,7 +83,7 @@ namespace FreeSql.Tests.OracleExpression { public void Minutes() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Minutes > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 60000000 mod 60) > 0) } @@ -91,7 +91,7 @@ namespace FreeSql.Tests.OracleExpression { public void Seconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Seconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 1000000 mod 60) > 0) } @@ -99,7 +99,7 @@ namespace FreeSql.Tests.OracleExpression { public void Ticks() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Ticks > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) * 10) > 0) } @@ -107,7 +107,7 @@ namespace FreeSql.Tests.OracleExpression { public void TotalDays() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalDays > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 86400000000) > 0) } @@ -115,7 +115,7 @@ namespace FreeSql.Tests.OracleExpression { public void TotalHours() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalHours > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 3600000000) > 0) } @@ -123,7 +123,7 @@ namespace FreeSql.Tests.OracleExpression { public void TotalMilliseconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalMilliseconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 1000) > 0) } @@ -131,7 +131,7 @@ namespace FreeSql.Tests.OracleExpression { public void TotalMinutes() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalMinutes > 0).ToSql()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 60000000) > 0) } @@ -139,7 +139,7 @@ namespace FreeSql.Tests.OracleExpression { public void TotalSeconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalSeconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 1000000) > 0) } @@ -147,7 +147,7 @@ namespace FreeSql.Tests.OracleExpression { public void Add() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Add(TimeSpan.FromDays(1)) > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) + (1 * 86400000000)) > 0) } @@ -155,7 +155,7 @@ namespace FreeSql.Tests.OracleExpression { public void Subtract() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Subtract(TimeSpan.FromDays(1)) > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) - (1 * 86400000000)) > 0) } @@ -163,7 +163,7 @@ namespace FreeSql.Tests.OracleExpression { public void CompareTo() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.CompareTo(TimeSpan.FromDays(1)) > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) - ((1 * 86400000000))) > 0) } @@ -171,7 +171,7 @@ namespace FreeSql.Tests.OracleExpression { public void this_Equals() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Equals(TimeSpan.FromDays(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) } @@ -179,7 +179,7 @@ namespace FreeSql.Tests.OracleExpression { public void this_ToString() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.ToString() == "ssss").ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (date_format(date_add(cast('0001/1/1 0:00:00' as datetime), interval (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) microsecond), '%Y-%m-%d %H:%i:%s.%f') = 'ssss') } @@ -188,7 +188,7 @@ namespace FreeSql.Tests.OracleExpression { public void TimeSpan_Compare() { var data = new List(); data.Add(select.Where(a => TimeSpan.Compare(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1)) > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) - ((1 * 86400000000))) > 0) } @@ -196,7 +196,7 @@ namespace FreeSql.Tests.OracleExpression { public void TimeSpan_Equals() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) } @@ -204,7 +204,7 @@ namespace FreeSql.Tests.OracleExpression { public void TimeSpan_FromDays() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) } @@ -212,7 +212,7 @@ namespace FreeSql.Tests.OracleExpression { public void TimeSpan_FromHours() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromHours(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 3600000000))) } @@ -220,7 +220,7 @@ namespace FreeSql.Tests.OracleExpression { public void TimeSpan_FromMilliseconds() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromMilliseconds(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 1000))) } @@ -228,7 +228,7 @@ namespace FreeSql.Tests.OracleExpression { public void TimeSpan_FromMinutes() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromMinutes(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 60000000))) } @@ -236,7 +236,7 @@ namespace FreeSql.Tests.OracleExpression { public void TimeSpan_FromSeconds() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromSeconds(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 1000000))) } @@ -244,7 +244,7 @@ namespace FreeSql.Tests.OracleExpression { public void TimeSpan_FromTicks() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromTicks(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 / 10))) } @@ -252,7 +252,7 @@ namespace FreeSql.Tests.OracleExpression { public void TimeSpan_Parse() { var data = new List(); data.Add(select.Where(a => TimeSpan.Parse(a.CreateTime.TimeOfDay.ToString()) > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (cast(date_format(date_add(cast('0001/1/1 0:00:00' as datetime), interval (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) microsecond), '%Y-%m-%d %H:%i:%s.%f') as signed) > 0) } diff --git a/FreeSql.Tests/PostgreSQL/Curd/PostgreSQLSelectTest.cs b/FreeSql.Tests/PostgreSQL/Curd/PostgreSQLSelectTest.cs index d72fecb2..0ab9532c 100644 --- a/FreeSql.Tests/PostgreSQL/Curd/PostgreSQLSelectTest.cs +++ b/FreeSql.Tests/PostgreSQL/Curd/PostgreSQLSelectTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.PostgreSQL { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -53,8 +53,8 @@ namespace FreeSql.Tests.PostgreSQL { var t2 = g.pgsql.Select().As("b").Where("").Where(a => a.Id > 0).Skip(100).Limit(200).ToSql(); - var sql1 = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid).ToSql(); - var sql2 = select.LeftJoin((a, b) => a.TestTypeInfoGuid == b.Guid && b.Name == "111").ToSql(); + var sql1 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).ToSql(); + var sql2 = select.LeftJoin((a, b) => a.TypeGuid == b.Guid && b.Name == "111").ToSql(); var sql3 = select.LeftJoin("TestTypeInfo b on b.Guid = a.TypeGuid").ToSql(); //g.pgsql.Select().Join((a, b, c) => new Model.JoinResult3( @@ -69,14 +69,14 @@ namespace FreeSql.Tests.PostgreSQL { //.Where(a => a.Id == 1).ToSql(); var sql4 = select.From((s, b, c) => s - .InnerJoin(a => a.TestTypeInfoGuid == b.Guid) + .InnerJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => c.Id == b.ParentId) .Where(a => b.Name == "xxx")).ToSql(); //.Where(a => a.Id == 1).ToSql(); var list111 = select.From((s, b, c) => s - .InnerJoin(a => a.TestTypeInfoGuid == b.Guid) + .InnerJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => c.Id == b.ParentId) .Where(a => b.Name != "xxx")); var list111sql = list111.ToSql(); @@ -149,7 +149,7 @@ namespace FreeSql.Tests.PostgreSQL { var sql2222Tolist = sql2222.ToList(); var collectionSelect = select.Where(a => - a.Type.Guid == a.TestTypeInfoGuid && + a.Type.Guid == a.TypeGuid && a.Type.Parent.Id == a.Type.ParentId && a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any(b => b.ParentId == a.Type.Parent.Id) ); @@ -180,216 +180,216 @@ namespace FreeSql.Tests.PostgreSQL { public void From() { //������� var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id) ); var sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b ON a.\"testtypeinfoguid\" = b.\"guid\" LEFT JOIN \"testtypeparentinfo\" c ON b.\"parentid\" = c.\"id\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b ON a.\"TypeGuid\" = b.\"guid\" LEFT JOIN \"testtypeparentinfo\" c ON b.\"parentid\" = c.\"id\"", sql); query2.ToList(); } [Fact] public void LeftJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\" AND a__Type.\"name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\" AND a__Type.\"name\" = 'xxx'", sql); query.ToList(); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeparentinfo\" a__Type__Parent ON 1 = 1 LEFT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\" AND a__Type.\"name\" = 'xxx' WHERE (a__Type__Parent.\"id\" = 10)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeparentinfo\" a__Type__Parent ON 1 = 1 LEFT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\" AND a__Type.\"name\" = 'xxx' WHERE (a__Type__Parent.\"id\" = 10)", sql); query.ToList(); //���û�е������� - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"testtypeinfoguid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"testtypeinfoguid\" AND b.\"name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"TypeGuid\" AND b.\"name\" = 'xxx'", sql); query.ToList(); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeparentinfo\" b__Parent ON 1 = 1 LEFT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"testtypeinfoguid\" AND b.\"name\" = 'xxx' WHERE (b__Parent.\"id\" = 10)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeparentinfo\" b__Parent ON 1 = 1 LEFT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"TypeGuid\" AND b.\"name\" = 'xxx' WHERE (b__Parent.\"id\" = 10)", sql); query.ToList(); //������� query = select - .LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .LeftJoin(a => a.Type.Guid == a.TypeGuid) .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\" LEFT JOIN \"testtypeparentinfo\" a__Type__Parent ON a__Type__Parent.\"id\" = a__Type.\"parentid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\" LEFT JOIN \"testtypeparentinfo\" a__Type__Parent ON a__Type__Parent.\"id\" = a__Type.\"parentid\"", sql); query.ToList(); query = select - .LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .LeftJoin((a, b) => b.Guid == a.TypeGuid) .LeftJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"testtypeinfoguid\" LEFT JOIN \"testtypeparentinfo\" c ON c.\"id\" = b.\"parentid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"TypeGuid\" LEFT JOIN \"testtypeparentinfo\" c ON c.\"id\" = b.\"parentid\"", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b ON a.\"testtypeinfoguid\" = b.\"guid\" LEFT JOIN \"testtypeparentinfo\" c ON b.\"parentid\" = c.\"id\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b ON a.\"TypeGuid\" = b.\"guid\" LEFT JOIN \"testtypeparentinfo\" c ON b.\"parentid\" = c.\"id\"", sql); query2.ToList(); //������϶����㲻�� - query = select.LeftJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\""); + query = select.LeftJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\""); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.LeftJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\" and b.\"name\" = @bname", new { bname = "xxx" }); + query = select.LeftJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\" and b.\"name\" = @bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\" and b.\"name\" = @bname", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\" and b.\"name\" = @bname", sql); query.ToList(); } [Fact] public void InnerJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\" AND a__Type.\"name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\" AND a__Type.\"name\" = 'xxx'", sql); query.ToList(); - query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeparentinfo\" a__Type__Parent ON 1 = 1 INNER JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\" AND a__Type.\"name\" = 'xxx' WHERE (a__Type__Parent.\"id\" = 10)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeparentinfo\" a__Type__Parent ON 1 = 1 INNER JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\" AND a__Type.\"name\" = 'xxx' WHERE (a__Type__Parent.\"id\" = 10)", sql); query.ToList(); //���û�е������� - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"testtypeinfoguid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"testtypeinfoguid\" AND b.\"name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"TypeGuid\" AND b.\"name\" = 'xxx'", sql); query.ToList(); - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeparentinfo\" b__Parent ON 1 = 1 INNER JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"testtypeinfoguid\" AND b.\"name\" = 'xxx' WHERE (b__Parent.\"id\" = 10)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeparentinfo\" b__Parent ON 1 = 1 INNER JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"TypeGuid\" AND b.\"name\" = 'xxx' WHERE (b__Parent.\"id\" = 10)", sql); query.ToList(); //������� query = select - .InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .InnerJoin(a => a.Type.Guid == a.TypeGuid) .InnerJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\" INNER JOIN \"testtypeparentinfo\" a__Type__Parent ON a__Type__Parent.\"id\" = a__Type.\"parentid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\" INNER JOIN \"testtypeparentinfo\" a__Type__Parent ON a__Type__Parent.\"id\" = a__Type.\"parentid\"", sql); query.ToList(); query = select - .InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .InnerJoin((a, b) => b.Guid == a.TypeGuid) .InnerJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"testtypeinfoguid\" INNER JOIN \"testtypeparentinfo\" c ON c.\"id\" = b.\"parentid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"TypeGuid\" INNER JOIN \"testtypeparentinfo\" c ON c.\"id\" = b.\"parentid\"", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .InnerJoin(a => a.TestTypeInfoGuid == b.Guid) + .InnerJoin(a => a.TypeGuid == b.Guid) .InnerJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" b ON a.\"testtypeinfoguid\" = b.\"guid\" INNER JOIN \"testtypeparentinfo\" c ON b.\"parentid\" = c.\"id\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" b ON a.\"TypeGuid\" = b.\"guid\" INNER JOIN \"testtypeparentinfo\" c ON b.\"parentid\" = c.\"id\"", sql); query2.ToList(); //������϶����㲻�� - query = select.InnerJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\""); + query = select.InnerJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\""); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.InnerJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\" and b.\"name\" = @bname", new { bname = "xxx" }); + query = select.InnerJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\" and b.\"name\" = @bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\" and b.\"name\" = @bname", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a INNER JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\" and b.\"name\" = @bname", sql); query.ToList(); } [Fact] public void RightJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.RightJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.RightJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\" AND a__Type.\"name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\" AND a__Type.\"name\" = 'xxx'", sql); query.ToList(); - query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.RightJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeparentinfo\" a__Type__Parent ON 1 = 1 RIGHT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\" AND a__Type.\"name\" = 'xxx' WHERE (a__Type__Parent.\"id\" = 10)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeparentinfo\" a__Type__Parent ON 1 = 1 RIGHT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\" AND a__Type.\"name\" = 'xxx' WHERE (a__Type__Parent.\"id\" = 10)", sql); query.ToList(); //���û�е������� - query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.RightJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"testtypeinfoguid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.RightJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"testtypeinfoguid\" AND b.\"name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"TypeGuid\" AND b.\"name\" = 'xxx'", sql); query.ToList(); - query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.RightJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeparentinfo\" b__Parent ON 1 = 1 RIGHT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"testtypeinfoguid\" AND b.\"name\" = 'xxx' WHERE (b__Parent.\"id\" = 10)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a LEFT JOIN \"testtypeparentinfo\" b__Parent ON 1 = 1 RIGHT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"TypeGuid\" AND b.\"name\" = 'xxx' WHERE (b__Parent.\"id\" = 10)", sql); query.ToList(); //������� query = select - .RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .RightJoin(a => a.Type.Guid == a.TypeGuid) .RightJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\" RIGHT JOIN \"testtypeparentinfo\" a__Type__Parent ON a__Type__Parent.\"id\" = a__Type.\"parentid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\" RIGHT JOIN \"testtypeparentinfo\" a__Type__Parent ON a__Type__Parent.\"id\" = a__Type.\"parentid\"", sql); query.ToList(); query = select - .RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .RightJoin((a, b) => b.Guid == a.TypeGuid) .RightJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"testtypeinfoguid\" RIGHT JOIN \"testtypeparentinfo\" c ON c.\"id\" = b.\"parentid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" b ON b.\"guid\" = a.\"TypeGuid\" RIGHT JOIN \"testtypeparentinfo\" c ON c.\"id\" = b.\"parentid\"", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .RightJoin(a => a.TestTypeInfoGuid == b.Guid) + .RightJoin(a => a.TypeGuid == b.Guid) .RightJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" b ON a.\"testtypeinfoguid\" = b.\"guid\" RIGHT JOIN \"testtypeparentinfo\" c ON b.\"parentid\" = c.\"id\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" b ON a.\"TypeGuid\" = b.\"guid\" RIGHT JOIN \"testtypeparentinfo\" c ON b.\"parentid\" = c.\"id\"", sql); query2.ToList(); //������϶����㲻�� - query = select.RightJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\""); + query = select.RightJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\""); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.RightJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\" and b.\"name\" = @bname", new { bname = "xxx" }); + query = select.RightJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\" and b.\"name\" = @bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\" and b.\"name\" = @bname", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a RIGHT JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\" and b.\"name\" = @bname", sql); query.ToList(); } @@ -398,48 +398,48 @@ namespace FreeSql.Tests.PostgreSQL { //����е�������a.Type��a.Type.Parent ���ǵ������� var query = select.Where(a => a.Id == 10); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"id\" = 10)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"id\" = 10)", sql); query.ToList(); query = select.Where(a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"id\" = 10 AND a.\"id\" > 10 OR a.\"clicks\" > 100)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"id\" = 10 AND a.\"id\" > 10 OR a.\"clicks\" > 100)", sql); query.ToList(); query = select.Where(a => a.Id == 10).Where(a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"id\" = 10) AND (a.\"clicks\" > 100)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"id\" = 10) AND (a.\"clicks\" > 100)", sql); query.ToList(); query = select.Where(a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle')", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle')", sql); query.ToList(); - query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle' AND a__Type.\"guid\" = a.\"testtypeinfoguid\")", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle' AND a__Type.\"guid\" = a.\"TypeGuid\")", sql); query.ToList(); query = select.Where(a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type, \"testtypeparentinfo\" a__Type__Parent WHERE (a__Type__Parent.\"name\" = 'tparent')", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type, \"testtypeparentinfo\" a__Type__Parent WHERE (a__Type__Parent.\"name\" = 'tparent')", sql); query.ToList(); //���û�е������ԣ��򵥶������ - query = select.Where((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "typeTitle"); + query = select.Where((a, b) => b.Guid == a.TypeGuid && b.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" b WHERE (b.\"guid\" = a.\"testtypeinfoguid\" AND b.\"name\" = 'typeTitle')", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" b WHERE (b.\"guid\" = a.\"TypeGuid\" AND b.\"name\" = 'typeTitle')", sql); query.ToList(); - query = select.Where((a, b) => b.Name == "typeTitle" && b.Guid == a.TestTypeInfoGuid); + query = select.Where((a, b) => b.Name == "typeTitle" && b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" b WHERE (b.\"name\" = 'typeTitle' AND b.\"guid\" = a.\"testtypeinfoguid\")", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" b WHERE (b.\"name\" = 'typeTitle' AND b.\"guid\" = a.\"TypeGuid\")", sql); query.ToList(); query = select.Where((a, b, c) => c.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeparentinfo\" c WHERE (c.\"name\" = 'tparent')", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeparentinfo\" c WHERE (c.\"name\" = 'tparent')", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -447,13 +447,13 @@ namespace FreeSql.Tests.PostgreSQL { .Where(a => a.Id == 10 && c.Name == "xxx") .Where(a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeparentinfo\" c, \"testtypeinfo\" b WHERE (a.\"id\" = 10 AND c.\"name\" = 'xxx') AND (b.\"parentid\" = 20)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeparentinfo\" c, \"testtypeinfo\" b WHERE (a.\"id\" = 10 AND c.\"name\" = 'xxx') AND (b.\"parentid\" = 20)", sql); query2.ToList(); //������϶����㲻�� query = select.Where("a.\"clicks\" > 100 and a.\"id\" = @id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"clicks\" > 100 and a.\"id\" = @id)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"clicks\" > 100 and a.\"id\" = @id)", sql); query.ToList(); } [Fact] @@ -461,32 +461,32 @@ namespace FreeSql.Tests.PostgreSQL { //����е�������a.Type��a.Type.Parent ���ǵ������� var query = select.WhereIf(true, a => a.Id == 10); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"id\" = 10)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"id\" = 10)", sql); query.ToList(); query = select.WhereIf(true, a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"id\" = 10 AND a.\"id\" > 10 OR a.\"clicks\" > 100)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"id\" = 10 AND a.\"id\" > 10 OR a.\"clicks\" > 100)", sql); query.ToList(); query = select.WhereIf(true, a => a.Id == 10).WhereIf(true, a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"id\" = 10) AND (a.\"clicks\" > 100)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"id\" = 10) AND (a.\"clicks\" > 100)", sql); query.ToList(); query = select.WhereIf(true, a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle')", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle')", sql); query.ToList(); - query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle' AND a__Type.\"guid\" = a.\"testtypeinfoguid\")", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle' AND a__Type.\"guid\" = a.\"TypeGuid\")", sql); query.ToList(); query = select.WhereIf(true, a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type, \"testtypeparentinfo\" a__Type__Parent WHERE (a__Type__Parent.\"name\" = 'tparent')", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type, \"testtypeparentinfo\" a__Type__Parent WHERE (a__Type__Parent.\"name\" = 'tparent')", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -494,13 +494,13 @@ namespace FreeSql.Tests.PostgreSQL { .WhereIf(true, a => a.Id == 10 && c.Name == "xxx") .WhereIf(true, a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeparentinfo\" c, \"testtypeinfo\" b WHERE (a.\"id\" = 10 AND c.\"name\" = 'xxx') AND (b.\"parentid\" = 20)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeparentinfo\" c, \"testtypeinfo\" b WHERE (a.\"id\" = 10 AND c.\"name\" = 'xxx') AND (b.\"parentid\" = 20)", sql); query2.ToList(); //������϶����㲻�� query = select.WhereIf(true, "a.\"clicks\" > 100 and a.\"id\" = @id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"clicks\" > 100 and a.\"id\" = @id)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a WHERE (a.\"clicks\" > 100 and a.\"id\" = @id)", sql); query.ToList(); // ==========================================WhereIf(false) @@ -508,32 +508,32 @@ namespace FreeSql.Tests.PostgreSQL { //����е�������a.Type��a.Type.Parent ���ǵ������� query = select.WhereIf(false, a => a.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); query.ToList(); query = select.WhereIf(false, a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); query.ToList(); query = select.WhereIf(false, a => a.Id == 10).WhereIf(false, a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); query.ToList(); query = select.WhereIf(false, a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); query.ToList(); - query = select.WhereIf(false, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.WhereIf(false, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); query.ToList(); query = select.WhereIf(false, a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -541,13 +541,13 @@ namespace FreeSql.Tests.PostgreSQL { .WhereIf(false, a => a.Id == 10 && c.Name == "xxx") .WhereIf(false, a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); query2.ToList(); //������϶����㲻�� query = select.WhereIf(false, "a.\"clicks\" > 100 and a.\"id\" = @id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a", sql); query.ToList(); } [Fact] @@ -622,59 +622,59 @@ namespace FreeSql.Tests.PostgreSQL { }; //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid).AsTable(tableRule); + var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).AsTable(tableRule); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\"", sql); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").AsTable(tableRule); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\" AND a__Type.\"name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\" AND a__Type.\"name\" = 'xxx'", sql); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeparentinfoAsTable\" a__Type__Parent ON 1 = 1 LEFT JOIN \"testtypeinfoAsTable2\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\" AND a__Type.\"name\" = 'xxx' WHERE (a__Type__Parent.\"id\" = 10)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeparentinfoAsTable\" a__Type__Parent ON 1 = 1 LEFT JOIN \"testtypeinfoAsTable2\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\" AND a__Type.\"name\" = 'xxx' WHERE (a__Type__Parent.\"id\" = 10)", sql); //���û�е������� - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid).AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" b ON b.\"guid\" = a.\"testtypeinfoguid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" b ON b.\"guid\" = a.\"TypeGuid\"", sql); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" b ON b.\"guid\" = a.\"testtypeinfoguid\" AND b.\"name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" b ON b.\"guid\" = a.\"TypeGuid\" AND b.\"name\" = 'xxx'", sql); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeparentinfoAsTable\" b__Parent ON 1 = 1 LEFT JOIN \"testtypeinfoAsTable2\" b ON b.\"guid\" = a.\"testtypeinfoguid\" AND b.\"name\" = 'xxx' WHERE (b__Parent.\"id\" = 10)", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeparentinfoAsTable\" b__Parent ON 1 = 1 LEFT JOIN \"testtypeinfoAsTable2\" b ON b.\"guid\" = a.\"TypeGuid\" AND b.\"name\" = 'xxx' WHERE (b__Parent.\"id\" = 10)", sql); //������� query = select - .LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .LeftJoin(a => a.Type.Guid == a.TypeGuid) .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" a__Type ON a__Type.\"guid\" = a.\"testtypeinfoguid\" LEFT JOIN \"testtypeparentinfoAsTable\" a__Type__Parent ON a__Type__Parent.\"id\" = a__Type.\"parentid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" a__Type ON a__Type.\"guid\" = a.\"TypeGuid\" LEFT JOIN \"testtypeparentinfoAsTable\" a__Type__Parent ON a__Type__Parent.\"id\" = a__Type.\"parentid\"", sql); query = select - .LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .LeftJoin((a, b) => b.Guid == a.TypeGuid) .LeftJoin((a, c) => c.Id == a.Type.ParentId).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" b ON b.\"guid\" = a.\"testtypeinfoguid\" LEFT JOIN \"testtypeparentinfoAsTable\" c ON c.\"id\" = b.\"parentid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" b ON b.\"guid\" = a.\"TypeGuid\" LEFT JOIN \"testtypeparentinfoAsTable\" c ON c.\"id\" = b.\"parentid\"", sql); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id)).AsTable(tableRule); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" b ON a.\"testtypeinfoguid\" = b.\"guid\" LEFT JOIN \"testtypeparentinfoAsTable\" c ON b.\"parentid\" = c.\"id\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfoAsTable2\" b ON a.\"TypeGuid\" = b.\"guid\" LEFT JOIN \"testtypeparentinfoAsTable\" c ON b.\"parentid\" = c.\"id\"", sql); //������϶����㲻�� - query = select.LeftJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\"").AsTable(tableRule); + query = select.LeftJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\"").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\"", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\"", sql); - query = select.LeftJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\" and b.\"name\" = @bname", new { bname = "xxx" }).AsTable(tableRule); + query = select.LeftJoin("\"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\" and b.\"name\" = @bname", new { bname = "xxx" }).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"testtypeinfoguid\" and b.\"name\" = @bname", sql); + Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"TypeGuid\", a.\"title\", a.\"createtime\" FROM \"tb_topicAsTable1\" a LEFT JOIN \"testtypeinfo\" b on b.\"guid\" = a.\"TypeGuid\" and b.\"name\" = @bname", sql); } } } diff --git a/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/ConvertTest.cs b/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/ConvertTest.cs index 2a977211..a7ceda76 100644 --- a/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/ConvertTest.cs +++ b/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/ConvertTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -36,7 +36,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void ToBoolean() { var data = new List(); data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 2) > 0).ToList()); - //SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` + //SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` //FROM `tb_topic` a //WHERE ((a.`Clicks` not in ('0','false'))) } diff --git a/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/DateTimeTest.cs b/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/DateTimeTest.cs index cb3a3e08..e3f0d329 100644 --- a/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/DateTimeTest.cs +++ b/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/DateTimeTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -39,7 +39,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void Now() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.Now.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(now(), '%Y-%m-%d') as datetime)) } @@ -47,7 +47,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void UtcNow() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.UtcNow.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(utc_timestamp(), '%Y-%m-%d') as datetime)) } @@ -55,7 +55,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void MinValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.MinValue.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(cast('0001/1/1 0:00:00' as datetime), '%Y-%m-%d') as datetime)) } @@ -63,7 +63,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void MaxValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.MaxValue.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(cast('9999/12/31 23:59:59' as datetime), '%Y-%m-%d') as datetime)) } @@ -73,29 +73,29 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.Date == DateTime.Now.Date).ToList()); data.Add(select.Where(a => a.Type.Time.Date > DateTime.Now.Date).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Date > DateTime.Now.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(now(), '%Y-%m-%d') as datetime)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (cast(date_format(a__Type.`Time`, '%Y-%m-%d') as datetime) > cast(date_format(now(), '%Y-%m-%d') as datetime)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (cast(date_format(a__Type__Parent.`Time2`, '%Y-%m-%d') as datetime) > cast(date_format(now(), '%Y-%m-%d') as datetime)); data.Add(select.Where(a => DateTime.Now.Subtract(a.CreateTime.Date).TotalSeconds > 0).ToList()); data.Add(select.Where(a => DateTime.Now.Subtract(a.Type.Time.Date).TotalSeconds > 0).ToList()); data.Add(select.Where(a => DateTime.Now.Subtract(a.Type.Parent.Time2.Date).TotalSeconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((timestampdiff(microsecond, cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((timestampdiff(microsecond, cast(date_format(a__Type.`Time`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((timestampdiff(microsecond, cast(date_format(a__Type__Parent.`Time2`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0) } @@ -105,15 +105,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.TimeOfDay == DateTime.Now.TimeOfDay).ToList()); data.Add(select.Where(a => a.Type.Time.TimeOfDay > DateTime.Now.TimeOfDay).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.TimeOfDay > DateTime.Now.TimeOfDay).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((timestampdiff(microsecond, date_format(a__Type.`Time`, '1970-1-1 %H:%i:%s.%f'), a__Type.`Time`) + 62135596800000000) > (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((timestampdiff(microsecond, date_format(a__Type__Parent.`Time2`, '1970-1-1 %H:%i:%s.%f'), a__Type__Parent.`Time2`) + 62135596800000000) > (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)) } @@ -123,15 +123,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); data.Add(select.Where(a => a.Type.Time.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((dayofweek(a.`CreateTime`) - 1) > (dayofweek(now()) - 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((dayofweek(a__Type.`Time`) - 1) > (dayofweek(now()) - 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((dayofweek(a__Type__Parent.`Time2`) - 1) > (dayofweek(now()) - 1)) } @@ -141,15 +141,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.Day > DateTime.Now.Day).ToList()); data.Add(select.Where(a => a.Type.Time.Day > DateTime.Now.Day).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Day > DateTime.Now.Day).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (dayofmonth(a.`CreateTime`) > dayofmonth(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (dayofmonth(a__Type.`Time`) > dayofmonth(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (dayofmonth(a__Type__Parent.`Time2`) > dayofmonth(now())) } @@ -159,15 +159,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.DayOfYear > DateTime.Now.DayOfYear).ToList()); data.Add(select.Where(a => a.Type.Time.DayOfYear > DateTime.Now.DayOfYear).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.DayOfYear > DateTime.Now.DayOfYear).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (dayofyear(a.`CreateTime`) > dayofyear(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (dayofyear(a__Type.`Time`) > dayofyear(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (dayofyear(a__Type__Parent.`Time2`) > dayofyear(now())) } @@ -177,15 +177,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.Month > DateTime.Now.Month).ToList()); data.Add(select.Where(a => a.Type.Time.Month > DateTime.Now.Month).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Month > DateTime.Now.Month).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (month(a.`CreateTime`) > month(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (month(a__Type.`Time`) > month(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (month(a__Type__Parent.`Time2`) > month(now())) } @@ -195,15 +195,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.Year > DateTime.Now.Year).ToList()); data.Add(select.Where(a => a.Type.Time.Year > DateTime.Now.Year).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Year > DateTime.Now.Year).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (year(a.`CreateTime`) > year(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (year(a__Type.`Time`) > year(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (year(a__Type__Parent.`Time2`) > year(now())) } @@ -213,15 +213,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.Hour > DateTime.Now.Hour).ToList()); data.Add(select.Where(a => a.Type.Time.Hour > DateTime.Now.Hour).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Hour > DateTime.Now.Hour).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (hour(a.`CreateTime`) > hour(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (hour(a__Type.`Time`) > hour(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (hour(a__Type__Parent.`Time2`) > hour(now())) } @@ -231,15 +231,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.Minute > DateTime.Now.Minute).ToList()); data.Add(select.Where(a => a.Type.Time.Minute > DateTime.Now.Minute).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Minute > DateTime.Now.Minute).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (minute(a.`CreateTime`) > minute(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (minute(a__Type.`Time`) > minute(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (minute(a__Type__Parent.`Time2`) > minute(now())) } @@ -249,15 +249,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.Second > DateTime.Now.Second).ToList()); data.Add(select.Where(a => a.Type.Time.Second > DateTime.Now.Second).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Second > DateTime.Now.Second).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (second(a.`CreateTime`) > second(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (second(a__Type.`Time`) > second(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (second(a__Type__Parent.`Time2`) > second(now())) } @@ -267,15 +267,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.Millisecond > DateTime.Now.Millisecond).ToList()); data.Add(select.Where(a => a.Type.Time.Millisecond > DateTime.Now.Millisecond).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Millisecond > DateTime.Now.Millisecond).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (floor(microsecond(a.`CreateTime`) / 1000) > floor(microsecond(now()) / 1000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (floor(microsecond(a__Type.`Time`) / 1000) > floor(microsecond(now()) / 1000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (floor(microsecond(a__Type__Parent.`Time2`) / 1000) > floor(microsecond(now()) / 1000)) } @@ -285,15 +285,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.Ticks > DateTime.Now.Ticks).ToList()); data.Add(select.Where(a => a.Type.Time.Ticks > DateTime.Now.Ticks).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Ticks > DateTime.Now.Ticks).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((timestampdiff(microsecond, '1970-1-1', a.`CreateTime`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((timestampdiff(microsecond, '1970-1-1', a__Type.`Time`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((timestampdiff(microsecond, '1970-1-1', a__Type__Parent.`Time2`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)) } @@ -303,15 +303,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval ((1 * 86400000000)) microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval ((1 * 86400000000)) microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval ((1 * 86400000000)) microsecond) > now()) } @@ -321,15 +321,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.AddDays(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddDays(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddDays(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) day) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) day) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) day) > now()) } @@ -339,15 +339,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.AddHours(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddHours(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddHours(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) hour) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) hour) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) hour) > now()) } @@ -357,15 +357,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.AddMilliseconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddMilliseconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddMilliseconds(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) * 1000 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) * 1000 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) * 1000 microsecond) > now()) } @@ -375,15 +375,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.AddMinutes(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddMinutes(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddMinutes(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) minute) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) minute) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) minute) > now()) } @@ -393,15 +393,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.AddMonths(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddMonths(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddMonths(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) month) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) month) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) month) > now()) } @@ -411,15 +411,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.AddSeconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddSeconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddSeconds(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) second) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) second) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) second) > now()) } @@ -429,15 +429,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.AddTicks(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddTicks(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddTicks(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) / 10 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) / 10 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) / 10 microsecond) > now()) } @@ -447,15 +447,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.AddYears(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) year) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) year) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) year) > now()) } @@ -465,29 +465,29 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); data.Add(select.Where(a => a.Type.Time.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((timestampdiff(microsecond, now(), a.`CreateTime`)) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((timestampdiff(microsecond, now(), a__Type.`Time`)) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((timestampdiff(microsecond, now(), a__Type__Parent.`Time2`)) / 1000000) > 0); data.Add(select.Where(a => a.CreateTime.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); data.Add(select.Where(a => a.Type.Time.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_sub(a.`CreateTime`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_sub(a__Type.`Time`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_sub(a__Type__Parent.`Time2`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`) } @@ -497,15 +497,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.AddYears(1).Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1).Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).Equals(DateTime.Now)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((date_add(a.`CreateTime`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((date_add(a__Type.`Time`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((date_add(a__Type__Parent.`Time2`, interval (1) year) = now())) } @@ -515,15 +515,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.ToString().Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1).ToString().Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).ToString().Equals(DateTime.Now)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((date_format(a.`CreateTime`, '%Y-%m-%d %H:%i:%s.%f') = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((date_format(date_add(a__Type.`Time`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((date_format(date_add(a__Type__Parent.`Time2`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') = now())) } @@ -534,15 +534,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.CreateTime.CompareTo(DateTime.Now) == 0).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1).CompareTo(DateTime.Now) == 0).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).CompareTo(DateTime.Now) == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((a.`CreateTime`) - (now())) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((date_add(a__Type.`Time`, interval (1) year)) - (now())) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((date_add(a__Type__Parent.`Time2`, interval (1) year)) - (now())) = 0) } @@ -552,15 +552,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => DateTime.DaysInMonth(a.CreateTime.Year, a.CreateTime.Month) > 30).ToList()); data.Add(select.Where(a => DateTime.DaysInMonth(a.Type.Time.Year, a.Type.Time.Month) > 30).ToList()); data.Add(select.Where(a => DateTime.DaysInMonth(a.Type.Parent.Time2.Year, a.Type.Parent.Time2.Month) > 30).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (dayofmonth(last_day(concat(year(a.`CreateTime`), month(a.`CreateTime`), '-01'))) > 30); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (dayofmonth(last_day(concat(year(a__Type.`Time`), month(a__Type.`Time`), '-01'))) > 30); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (dayofmonth(last_day(concat(year(a__Type__Parent.`Time2`), month(a__Type__Parent.`Time2`), '-01'))) > 30) } @@ -570,15 +570,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => DateTime.Equals(a.CreateTime.AddYears(1), DateTime.Now)).ToList()); data.Add(select.Where(a => DateTime.Equals(a.Type.Time.AddYears(1), DateTime.Now)).ToList()); data.Add(select.Where(a => DateTime.Equals(a.Type.Parent.Time2.AddYears(1), DateTime.Now)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((date_add(a.`CreateTime`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((date_add(a__Type.`Time`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((date_add(a__Type__Parent.`Time2`, interval (1) year) = now())) } @@ -588,15 +588,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => DateTime.IsLeapYear(a.CreateTime.Year)).ToList()); data.Add(select.Where(a => DateTime.IsLeapYear(a.Type.Time.AddYears(1).Year)).ToList()); data.Add(select.Where(a => DateTime.IsLeapYear(a.Type.Parent.Time2.AddYears(1).Year)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((year(a.`CreateTime`)) % 4 = 0 AND (year(a.`CreateTime`)) % 100 <> 0 OR (year(a.`CreateTime`)) % 400 = 0)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((year(date_add(a__Type.`Time`, interval (1) year))) % 4 = 0 AND (year(date_add(a__Type.`Time`, interval (1) year))) % 100 <> 0 OR (year(date_add(a__Type.`Time`, interval (1) year))) % 400 = 0)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 4 = 0 AND (year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 100 <> 0 OR (year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 400 = 0)) } @@ -606,15 +606,15 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => DateTime.Parse(a.CreateTime.ToString()) > DateTime.Now).ToList()); data.Add(select.Where(a => DateTime.Parse(a.Type.Time.AddYears(1).ToString()) > DateTime.Now).ToList()); data.Add(select.Where(a => DateTime.Parse(a.Type.Parent.Time2.AddYears(1).ToString()) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (cast(date_format(date_add(a__Type.`Time`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (cast(date_format(date_add(a__Type__Parent.`Time2`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()) } diff --git a/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/MathTest.cs b/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/MathTest.cs index 9cc9dba0..a107ce57 100644 --- a/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/MathTest.cs +++ b/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/MathTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } diff --git a/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/StringTest.cs b/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/StringTest.cs index e3f53b68..50cad100 100644 --- a/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/StringTest.cs +++ b/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/StringTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -36,7 +36,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void Empty() { var data = new List(); data.Add(select.Where(a => (a.Title ?? "") == string.Empty).ToSql()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (ifnull(a.`Title`, '') = '') } @@ -48,38 +48,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { list.Add(select.Where(a => a.Title.StartsWith(a.Title)).ToList()); list.Add(select.Where(a => a.Title.StartsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => a.Title.StartsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE '%aaa') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', a.`Title`)) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', concat(a.`Title`, 1))) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((a.`Title`) LIKE concat('%', a__Type.`Name`)) list.Add(select.Where(a => (a.Title + "aaa").StartsWith("aaa")).ToList()); list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Title)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE '%aaa') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a.`Title`)) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', concat(a.`Title`, 1))) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`)) } @@ -90,38 +90,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { list.Add(select.Where(a => a.Title.EndsWith(a.Title)).ToList()); list.Add(select.Where(a => a.Title.EndsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => a.Title.EndsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE 'aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat(a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat(concat(a.`Title`, 1), '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((a.`Title`) LIKE concat(a__Type.`Name`, '%')) list.Add(select.Where(a => (a.Title + "aaa").EndsWith("aaa")).ToList()); list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Title)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE 'aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat(a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat(concat(a.`Title`, 1), '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((concat(a.`Title`, 'aaa')) LIKE concat(a__Type.`Name`, '%')) } @@ -132,38 +132,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { list.Add(select.Where(a => a.Title.Contains(a.Title)).ToList()); list.Add(select.Where(a => a.Title.Contains(a.Title + 1)).ToList()); list.Add(select.Where(a => a.Title.Contains(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE '%aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', a.`Title` +1, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((a.`Title`) LIKE concat('%', a__Type.`Name`, '%')) list.Add(select.Where(a => (a.Title + "aaa").Contains("aaa")).ToList()); list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title + 1)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE '%aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', concat(a.`Title`, 1), '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`, '%')) } @@ -174,38 +174,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.Title.ToLower() == a.Title).ToList()); data.Add(select.Where(a => a.Title.ToLower() == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.ToLower() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(a.`Title`) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE(lower(a.`Title`) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == a.Title).ToList()); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = a__Type.`Name`) } @@ -216,38 +216,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.Title.ToUpper() == a.Title).ToList()); data.Add(select.Where(a => a.Title.ToUpper() == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.ToUpper() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(a.`Title`) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (upper(a.`Title`) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == a.Title).ToList()); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = a__Type.`Name`) } @@ -258,38 +258,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.Title.Substring(0) == a.Title).ToList()); data.Add(select.Where(a => a.Title.Substring(0) == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.Substring(0) == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(a.`Title`, 1) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(a.`Title`, 1) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(a.`Title`, 1) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (substr(a.`Title`, 1) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(a.Title.Length) == "aaa").ToList()); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(0, a.Title.Length) == a.Title).ToList()); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(0, 3) == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(1, 2) == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), char_length(a.`Title`) + 1) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 1, char_length(a.`Title`)) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 1, 3) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 2, 2) = a__Type.`Name`) } @@ -300,38 +300,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.Title.Length == 1).ToList()); data.Add(select.Where(a => a.Title.Length == a.Title.Length + 1).ToList()); data.Add(select.Where(a => a.Title.Length == a.Type.Name.Length).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(a.`Title`) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(a.`Title`) = 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(a.`Title`) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (char_length(a.`Title`) = char_length(a__Type.`Name`)); data.Add(select.Where(a => (a.Title + "aaa").Length == 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").Length == 1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").Length == a.Title.Length + 1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").Length == a.Type.Name.Length).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(concat(a.`Title`, 'aaa')) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(concat(a.`Title`, 'aaa')) = 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(concat(a.`Title`, 'aaa')) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (char_length(concat(a.`Title`, 'aaa')) = char_length(a__Type.`Name`)) } @@ -342,38 +342,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == -1).ToList()); data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == (a.Title.Length + 1)).ToList()); data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == a.Type.Name.Length + 1).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(a.`Title`, 'aaa') - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = char_length(a__Type.`Name`) + 1); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa") == -1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == -1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == (a.Title.Length + 1)).ToList()); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == a.Type.Name.Length + 1).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa') - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = char_length(a__Type.`Name`) + 1) } @@ -384,38 +384,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(a.`Title`, 10, 'a') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(a.`Title`, 10, 'a') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(a.`Title`, 10, 'a') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (lpad(a.`Title`, 10, 'a') = a__Type.`Name`); data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == "aaa").ToList()); data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a__Type.`Name`) } @@ -426,38 +426,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.Title.PadRight(10, 'a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.PadRight(10, 'a') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.PadRight(10, 'a') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(a.`Title`, 10, 'a') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(a.`Title`, 10, 'a') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(a.`Title`, 10, 'a') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (rpad(a.`Title`, 10, 'a') = a__Type.`Name`); data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == "aaa").ToList()); data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a__Type.`Name`) } @@ -468,38 +468,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.Title.Trim('a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.Trim('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.Trim('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('a' from a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('b' from trim('a' from a.`Title`)) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim('c' from trim('b' from trim('a' from a.`Title`))) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.Trim() + "aaa").Trim() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.Trim('a') + "aaa").Trim('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.Trim('a', 'b') + "aaa").Trim('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.Trim('a', 'b', 'c') + "aaa").Trim('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(concat(trim(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('a' from concat(trim('a' from a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('b' from trim('a' from concat(trim('b' from trim('a' from a.`Title`)), 'aaa'))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim('c' from trim('b' from trim('a' from concat(trim('c' from trim('b' from trim('a' from a.`Title`))), 'aaa')))) = a__Type.`Name`) } @@ -510,38 +510,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.Title.TrimStart('a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.TrimStart('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.TrimStart('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (ltrim(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from trim(leading 'a' from a.`Title`)) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))))) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.TrimStart() + "aaa").TrimStart() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.TrimStart('a') + "aaa").TrimStart('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.TrimStart('a', 'b') + "aaa").TrimStart('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.TrimStart('a', 'b', 'c') + "aaa").TrimStart('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (ltrim(concat(ltrim(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'a' from trim(leading 'a' from a.`Title`)), 'aaa'))) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))), 'aaa'))))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))))), 'aaa'))))))) = a__Type.`Name`) } @@ -552,38 +552,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.Title.TrimEnd('a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.TrimEnd('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rtrim(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(trailing 'a' from a.`Title`)) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from a.`Title`))) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.TrimEnd() + "aaa").TrimEnd() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.TrimEnd('a') + "aaa").TrimEnd('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.TrimEnd('a', 'b') + "aaa").TrimEnd('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.TrimEnd('a', 'b', 'c') + "aaa").TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rtrim(concat(rtrim(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from concat(trim(trailing 'a' from a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(trailing 'a' from concat(trim(trailing 'b' from trim(trailing 'a' from a.`Title`)), 'aaa'))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from concat(trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from a.`Title`))), 'aaa')))) = a__Type.`Name`) } @@ -594,38 +594,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c") == a.Title).ToList()); data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c").Replace("c", "a") == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c").Replace(a.Type.Name, "a") == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (replace(a.`Title`, 'a', 'b') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (replace(replace(a.`Title`, 'a', 'b'), 'b', 'c') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'c', 'a') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), a__Type.`Name`, 'a') = a__Type.`Name`); data.Add(select.Where(a => (a.Title.Replace("a", "b") + "aaa").TrimEnd() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c") + "aaa").TrimEnd('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c").Replace("c", "a") + "aaa").TrimEnd('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c").Replace(a.Type.Name, "a") + "aaa").TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (concat(replace(a.`Title`, 'a', 'b'), 'aaa') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (concat(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'aaa') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (concat(replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'c', 'a'), 'aaa') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (concat(replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), a__Type.`Name`, 'a'), 'aaa') = a__Type.`Name`) } @@ -636,38 +636,38 @@ namespace FreeSql.Tests.PostgreSQLExpression { data.Add(select.Where(a => a.Title.CompareTo(a.Title) > 0).ToList()); data.Add(select.Where(a => a.Title.CompareTo(a.Title + 1) == 0).ToList()); data.Add(select.Where(a => a.Title.CompareTo(a.Title + a.Type.Name) == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(a.`Title`, a.`Title`) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(a.`Title`, a.`Title`) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(a.`Title`, concat(a.`Title`, 1)) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (strcmp(a.`Title`, concat(a.`Title`, a__Type.`Name`)) = 0); data.Add(select.Where(a => (a.Title + "aaa").CompareTo("aaa") == 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Title) > 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Title + 1) == 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Type.Name) == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(concat(a.`Title`, 'aaa'), 'aaa') = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(concat(a.`Title`, 'aaa'), a.`Title`) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(concat(a.`Title`, 'aaa'), concat(a.`Title`, 1)) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (strcmp(concat(a.`Title`, 'aaa'), a__Type.`Name`) = 0) } diff --git a/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/TimeSpanTest.cs b/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/TimeSpanTest.cs index 2da7378e..320cca13 100644 --- a/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/TimeSpanTest.cs +++ b/FreeSql.Tests/PostgreSQL/PostgreSQLExpression/TimeSpanTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -35,7 +35,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void Zero() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) > 0) } @@ -43,7 +43,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void MinValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay > TimeSpan.MinValue).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) > -922337203685477580) } @@ -51,7 +51,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void MaxValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay < TimeSpan.MaxValue).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) < 922337203685477580) } @@ -59,7 +59,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void Days() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Days == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 86400000000) = 0) } @@ -67,7 +67,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void Hours() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Hours > 0).ToSql()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 3600000000) mod 24 > 0) } @@ -75,7 +75,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void Milliseconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Milliseconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 1000 mod 1000) > 0) } @@ -83,7 +83,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void Minutes() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Minutes > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 60000000 mod 60) > 0) } @@ -91,7 +91,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void Seconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Seconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 1000000 mod 60) > 0) } @@ -99,7 +99,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void Ticks() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Ticks > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) * 10) > 0) } @@ -107,7 +107,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TotalDays() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalDays > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 86400000000) > 0) } @@ -115,7 +115,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TotalHours() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalHours > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 3600000000) > 0) } @@ -123,7 +123,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TotalMilliseconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalMilliseconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 1000) > 0) } @@ -131,7 +131,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TotalMinutes() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalMinutes > 0).ToSql()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 60000000) > 0) } @@ -139,7 +139,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TotalSeconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalSeconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 1000000) > 0) } @@ -147,7 +147,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void Add() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Add(TimeSpan.FromDays(1)) > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) + (1 * 86400000000)) > 0) } @@ -155,7 +155,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void Subtract() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Subtract(TimeSpan.FromDays(1)) > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) - (1 * 86400000000)) > 0) } @@ -163,7 +163,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void CompareTo() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.CompareTo(TimeSpan.FromDays(1)) > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) - ((1 * 86400000000))) > 0) } @@ -171,7 +171,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void this_Equals() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Equals(TimeSpan.FromDays(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) } @@ -179,7 +179,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void this_ToString() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.ToString() == "ssss").ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (date_format(date_add(cast('0001/1/1 0:00:00' as datetime), interval (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) microsecond), '%Y-%m-%d %H:%i:%s.%f') = 'ssss') } @@ -188,7 +188,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TimeSpan_Compare() { var data = new List(); data.Add(select.Where(a => TimeSpan.Compare(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1)) > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) - ((1 * 86400000000))) > 0) } @@ -196,7 +196,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TimeSpan_Equals() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) } @@ -204,7 +204,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TimeSpan_FromDays() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) } @@ -212,7 +212,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TimeSpan_FromHours() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromHours(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 3600000000))) } @@ -220,7 +220,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TimeSpan_FromMilliseconds() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromMilliseconds(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 1000))) } @@ -228,7 +228,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TimeSpan_FromMinutes() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromMinutes(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 60000000))) } @@ -236,7 +236,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TimeSpan_FromSeconds() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromSeconds(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 1000000))) } @@ -244,7 +244,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TimeSpan_FromTicks() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromTicks(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 / 10))) } @@ -252,7 +252,7 @@ namespace FreeSql.Tests.PostgreSQLExpression { public void TimeSpan_Parse() { var data = new List(); data.Add(select.Where(a => TimeSpan.Parse(a.CreateTime.TimeOfDay.ToString()) > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (cast(date_format(date_add(cast('0001/1/1 0:00:00' as datetime), interval (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) microsecond), '%Y-%m-%d %H:%i:%s.%f') as signed) > 0) } diff --git a/FreeSql.Tests/SqlServer/Curd/SqlServerInsertTest.cs b/FreeSql.Tests/SqlServer/Curd/SqlServerInsertTest.cs index 87530539..a4263c55 100644 --- a/FreeSql.Tests/SqlServer/Curd/SqlServerInsertTest.cs +++ b/FreeSql.Tests/SqlServer/Curd/SqlServerInsertTest.cs @@ -23,7 +23,7 @@ namespace FreeSql.Tests.SqlServer { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int? Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -34,16 +34,16 @@ namespace FreeSql.Tests.SqlServer { var items = new List(); for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now }); - var sql = insert.IgnoreColumns(a => a.TestTypeInfoGuid).AppendData(items.First()).ToSql(); + var sql = insert.IgnoreColumns(a => a.TypeGuid).AppendData(items.First()).ToSql(); Assert.Equal("INSERT INTO [tb_topic]([Clicks], [Title], [CreateTime]) VALUES(@Clicks0, @Title0, @CreateTime0)", sql); - sql = insert.IgnoreColumns(a => a.TestTypeInfoGuid).AppendData(items).ToSql(); + sql = insert.IgnoreColumns(a => a.TypeGuid).AppendData(items).ToSql(); Assert.Equal("INSERT INTO [tb_topic]([Clicks], [Title], [CreateTime]) VALUES(@Clicks0, @Title0, @CreateTime0), (@Clicks1, @Title1, @CreateTime1), (@Clicks2, @Title2, @CreateTime2), (@Clicks3, @Title3, @CreateTime3), (@Clicks4, @Title4, @CreateTime4), (@Clicks5, @Title5, @CreateTime5), (@Clicks6, @Title6, @CreateTime6), (@Clicks7, @Title7, @CreateTime7), (@Clicks8, @Title8, @CreateTime8), (@Clicks9, @Title9, @CreateTime9)", sql); sql = insert.AppendData(items).InsertColumns(a => a.Title).ToSql(); Assert.Equal("INSERT INTO [tb_topic]([Title]) VALUES(@Title0), (@Title1), (@Title2), (@Title3), (@Title4), (@Title5), (@Title6), (@Title7), (@Title8), (@Title9)", sql); - sql = insert.IgnoreColumns(a => new { a.CreateTime, a.TestTypeInfoGuid }).AppendData(items).ToSql(); + sql = insert.IgnoreColumns(a => new { a.CreateTime, a.TypeGuid }).AppendData(items).ToSql(); Assert.Equal("INSERT INTO [tb_topic]([Clicks], [Title]) VALUES(@Clicks0, @Title0), (@Clicks1, @Title1), (@Clicks2, @Title2), (@Clicks3, @Title3), (@Clicks4, @Title4), (@Clicks5, @Title5), (@Clicks6, @Title6), (@Clicks7, @Title7), (@Clicks8, @Title8), (@Clicks9, @Title9)", sql); } @@ -63,10 +63,10 @@ namespace FreeSql.Tests.SqlServer { var items = new List(); for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now }); - var sql = insert.AppendData(items).IgnoreColumns(a => new { a.CreateTime, a.TestTypeInfoGuid }).ToSql(); + var sql = insert.AppendData(items).IgnoreColumns(a => new { a.CreateTime, a.TypeGuid }).ToSql(); Assert.Equal("INSERT INTO [tb_topic]([Clicks], [Title]) VALUES(@Clicks0, @Title0), (@Clicks1, @Title1), (@Clicks2, @Title2), (@Clicks3, @Title3), (@Clicks4, @Title4), (@Clicks5, @Title5), (@Clicks6, @Title6), (@Clicks7, @Title7), (@Clicks8, @Title8), (@Clicks9, @Title9)", sql); - sql = insert.AppendData(items).IgnoreColumns(a => new { a.Title, a.CreateTime, a.TestTypeInfoGuid }).ToSql(); + sql = insert.AppendData(items).IgnoreColumns(a => new { a.Title, a.CreateTime, a.TypeGuid }).ToSql(); Assert.Equal("INSERT INTO [tb_topic]([Clicks]) VALUES(@Clicks0), (@Clicks1), (@Clicks2), (@Clicks3), (@Clicks4), (@Clicks5), (@Clicks6), (@Clicks7), (@Clicks8), (@Clicks9)", sql); } [Fact] @@ -110,28 +110,28 @@ namespace FreeSql.Tests.SqlServer { var items = new List(); for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now }); - var sql = insert.IgnoreColumns(a => a.TestTypeInfoGuid).AppendData(items.First()).AsTable(a => "tb_topicAsTable").ToSql(); + var sql = insert.IgnoreColumns(a => a.TypeGuid).AppendData(items.First()).AsTable(a => "tb_topicAsTable").ToSql(); Assert.Equal("INSERT INTO [tb_topicAsTable]([Clicks], [Title], [CreateTime]) VALUES(@Clicks0, @Title0, @CreateTime0)", sql); - sql = insert.IgnoreColumns(a => a.TestTypeInfoGuid).AppendData(items).AsTable(a => "tb_topicAsTable").ToSql(); + sql = insert.IgnoreColumns(a => a.TypeGuid).AppendData(items).AsTable(a => "tb_topicAsTable").ToSql(); Assert.Equal("INSERT INTO [tb_topicAsTable]([Clicks], [Title], [CreateTime]) VALUES(@Clicks0, @Title0, @CreateTime0), (@Clicks1, @Title1, @CreateTime1), (@Clicks2, @Title2, @CreateTime2), (@Clicks3, @Title3, @CreateTime3), (@Clicks4, @Title4, @CreateTime4), (@Clicks5, @Title5, @CreateTime5), (@Clicks6, @Title6, @CreateTime6), (@Clicks7, @Title7, @CreateTime7), (@Clicks8, @Title8, @CreateTime8), (@Clicks9, @Title9, @CreateTime9)", sql); - sql = insert.IgnoreColumns(a => a.TestTypeInfoGuid).AppendData(items).InsertColumns(a => a.Title).AsTable(a => "tb_topicAsTable").ToSql(); + sql = insert.IgnoreColumns(a => a.TypeGuid).AppendData(items).InsertColumns(a => a.Title).AsTable(a => "tb_topicAsTable").ToSql(); Assert.Equal("INSERT INTO [tb_topicAsTable]([Title]) VALUES(@Title0), (@Title1), (@Title2), (@Title3), (@Title4), (@Title5), (@Title6), (@Title7), (@Title8), (@Title9)", sql); - sql = insert.IgnoreColumns(a => new { a.CreateTime, a.TestTypeInfoGuid }).AppendData(items).AsTable(a => "tb_topicAsTable").ToSql(); + sql = insert.IgnoreColumns(a => new { a.CreateTime, a.TypeGuid }).AppendData(items).AsTable(a => "tb_topicAsTable").ToSql(); Assert.Equal("INSERT INTO [tb_topicAsTable]([Clicks], [Title]) VALUES(@Clicks0, @Title0), (@Clicks1, @Title1), (@Clicks2, @Title2), (@Clicks3, @Title3), (@Clicks4, @Title4), (@Clicks5, @Title5), (@Clicks6, @Title6), (@Clicks7, @Title7), (@Clicks8, @Title8), (@Clicks9, @Title9)", sql); - sql = insert.IgnoreColumns(a => new { a.Title, a.TestTypeInfoGuid }).InsertColumns(a => a.Title).AppendData(items).AsTable(a => "tb_topicAsTable").ToSql(); + sql = insert.IgnoreColumns(a => new { a.Title, a.TypeGuid }).InsertColumns(a => a.Title).AppendData(items).AsTable(a => "tb_topicAsTable").ToSql(); Assert.Equal("INSERT INTO [tb_topicAsTable]([Title]) VALUES(@Title0), (@Title1), (@Title2), (@Title3), (@Title4), (@Title5), (@Title6), (@Title7), (@Title8), (@Title9)", sql); - sql = insert.IgnoreColumns(a => a.TestTypeInfoGuid).AppendData(items).InsertColumns(a => new { a.Title, a.Clicks }).AsTable(a => "tb_topicAsTable").ToSql(); + sql = insert.IgnoreColumns(a => a.TypeGuid).AppendData(items).InsertColumns(a => new { a.Title, a.Clicks }).AsTable(a => "tb_topicAsTable").ToSql(); Assert.Equal("INSERT INTO [tb_topicAsTable]([Clicks], [Title]) VALUES(@Clicks0, @Title0), (@Clicks1, @Title1), (@Clicks2, @Title2), (@Clicks3, @Title3), (@Clicks4, @Title4), (@Clicks5, @Title5), (@Clicks6, @Title6), (@Clicks7, @Title7), (@Clicks8, @Title8), (@Clicks9, @Title9)", sql); - sql = insert.IgnoreColumns(a => new { a.CreateTime, a.TestTypeInfoGuid }).AppendData(items).AsTable(a => "tb_topicAsTable").ToSql(); + sql = insert.IgnoreColumns(a => new { a.CreateTime, a.TypeGuid }).AppendData(items).AsTable(a => "tb_topicAsTable").ToSql(); Assert.Equal("INSERT INTO [tb_topicAsTable]([Clicks], [Title]) VALUES(@Clicks0, @Title0), (@Clicks1, @Title1), (@Clicks2, @Title2), (@Clicks3, @Title3), (@Clicks4, @Title4), (@Clicks5, @Title5), (@Clicks6, @Title6), (@Clicks7, @Title7), (@Clicks8, @Title8), (@Clicks9, @Title9)", sql); - sql = insert.IgnoreColumns(a => new { a.CreateTime, a.Title, a.TestTypeInfoGuid }).AppendData(items).AsTable(a => "tb_topicAsTable").ToSql(); + sql = insert.IgnoreColumns(a => new { a.CreateTime, a.Title, a.TypeGuid }).AppendData(items).AsTable(a => "tb_topicAsTable").ToSql(); Assert.Equal("INSERT INTO [tb_topicAsTable]([Clicks]) VALUES(@Clicks0), (@Clicks1), (@Clicks2), (@Clicks3), (@Clicks4), (@Clicks5), (@Clicks6), (@Clicks7), (@Clicks8), (@Clicks9)", sql); } } diff --git a/FreeSql.Tests/SqlServer/Curd/SqlServerSelectTest.cs b/FreeSql.Tests/SqlServer/Curd/SqlServerSelectTest.cs index eb0dbc92..4aecd32a 100644 --- a/FreeSql.Tests/SqlServer/Curd/SqlServerSelectTest.cs +++ b/FreeSql.Tests/SqlServer/Curd/SqlServerSelectTest.cs @@ -23,7 +23,7 @@ namespace FreeSql.Tests.SqlServer { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int? Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -82,7 +82,7 @@ namespace FreeSql.Tests.SqlServer { var sql2222Tolist = sql2222.ToList(); var collectionSelect = select.Where(a => - a.Type.Guid == a.TestTypeInfoGuid && + a.Type.Guid == a.TypeGuid && a.Type.Parent.Id == a.Type.ParentId && a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any(b => b.ParentId == a.Type.Parent.Id) ); @@ -113,216 +113,216 @@ namespace FreeSql.Tests.SqlServer { public void From() { //������� var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id) ); var sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] b ON a.[TestTypeInfoGuid] = b.[Guid] LEFT JOIN [TestTypeParentInfo] c ON b.[ParentId] = c.[Id]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] b ON a.[TypeGuid] = b.[Guid] LEFT JOIN [TestTypeParentInfo] c ON b.[ParentId] = c.[Id]", sql); query2.ToList(); } [Fact] public void LeftJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TypeGuid]", sql); query.ToList(); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid] AND a__Type.[Name] = 'xxx'", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TypeGuid] AND a__Type.[Name] = 'xxx'", sql); query.ToList(); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeParentInfo] a__Type__Parent ON 1 = 1 LEFT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid] AND a__Type.[Name] = 'xxx' WHERE (a__Type__Parent.[Id] = 10)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeParentInfo] a__Type__Parent ON 1 = 1 LEFT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TypeGuid] AND a__Type.[Name] = 'xxx' WHERE (a__Type__Parent.[Id] = 10)", sql); query.ToList(); //���û�е������� - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TestTypeInfoGuid]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TypeGuid]", sql); query.ToList(); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TestTypeInfoGuid] AND b.[Name] = 'xxx'", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TypeGuid] AND b.[Name] = 'xxx'", sql); query.ToList(); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeParentInfo] b__Parent ON 1 = 1 LEFT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TestTypeInfoGuid] AND b.[Name] = 'xxx' WHERE (b__Parent.[Id] = 10)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeParentInfo] b__Parent ON 1 = 1 LEFT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TypeGuid] AND b.[Name] = 'xxx' WHERE (b__Parent.[Id] = 10)", sql); query.ToList(); //������� query = select - .LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .LeftJoin(a => a.Type.Guid == a.TypeGuid) .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid] LEFT JOIN [TestTypeParentInfo] a__Type__Parent ON a__Type__Parent.[Id] = a__Type.[ParentId]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TypeGuid] LEFT JOIN [TestTypeParentInfo] a__Type__Parent ON a__Type__Parent.[Id] = a__Type.[ParentId]", sql); query.ToList(); query = select - .LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .LeftJoin((a, b) => b.Guid == a.TypeGuid) .LeftJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TestTypeInfoGuid] LEFT JOIN [TestTypeParentInfo] c ON c.[Id] = b.[ParentId]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TypeGuid] LEFT JOIN [TestTypeParentInfo] c ON c.[Id] = b.[ParentId]", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] b ON a.[TestTypeInfoGuid] = b.[Guid] LEFT JOIN [TestTypeParentInfo] c ON b.[ParentId] = c.[Id]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeInfo] b ON a.[TypeGuid] = b.[Guid] LEFT JOIN [TestTypeParentInfo] c ON b.[ParentId] = c.[Id]", sql); query2.ToList(); //������϶����㲻�� - query = select.LeftJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid"); + query = select.LeftJoin("TestTypeInfo b on b.Guid = a.TypeGuid"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN TestTypeInfo b on b.Guid = a.TypeGuid", sql); query.ToList(); - query = select.LeftJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = @bname", new { bname = "xxx" }); + query = select.LeftJoin("TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = @bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = @bname", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = @bname", sql); query.ToList(); } [Fact] public void InnerJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TypeGuid]", sql); query.ToList(); - query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid] AND a__Type.[Name] = 'xxx'", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TypeGuid] AND a__Type.[Name] = 'xxx'", sql); query.ToList(); - query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeParentInfo] a__Type__Parent ON 1 = 1 INNER JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid] AND a__Type.[Name] = 'xxx' WHERE (a__Type__Parent.[Id] = 10)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeParentInfo] a__Type__Parent ON 1 = 1 INNER JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TypeGuid] AND a__Type.[Name] = 'xxx' WHERE (a__Type__Parent.[Id] = 10)", sql); query.ToList(); //���û�е������� - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] b ON b.[Guid] = a.[TestTypeInfoGuid]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] b ON b.[Guid] = a.[TypeGuid]", sql); query.ToList(); - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] b ON b.[Guid] = a.[TestTypeInfoGuid] AND b.[Name] = 'xxx'", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] b ON b.[Guid] = a.[TypeGuid] AND b.[Name] = 'xxx'", sql); query.ToList(); - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeParentInfo] b__Parent ON 1 = 1 INNER JOIN [TestTypeInfo] b ON b.[Guid] = a.[TestTypeInfoGuid] AND b.[Name] = 'xxx' WHERE (b__Parent.[Id] = 10)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeParentInfo] b__Parent ON 1 = 1 INNER JOIN [TestTypeInfo] b ON b.[Guid] = a.[TypeGuid] AND b.[Name] = 'xxx' WHERE (b__Parent.[Id] = 10)", sql); query.ToList(); //������� query = select - .InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .InnerJoin(a => a.Type.Guid == a.TypeGuid) .InnerJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid] INNER JOIN [TestTypeParentInfo] a__Type__Parent ON a__Type__Parent.[Id] = a__Type.[ParentId]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TypeGuid] INNER JOIN [TestTypeParentInfo] a__Type__Parent ON a__Type__Parent.[Id] = a__Type.[ParentId]", sql); query.ToList(); query = select - .InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .InnerJoin((a, b) => b.Guid == a.TypeGuid) .InnerJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] b ON b.[Guid] = a.[TestTypeInfoGuid] INNER JOIN [TestTypeParentInfo] c ON c.[Id] = b.[ParentId]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] b ON b.[Guid] = a.[TypeGuid] INNER JOIN [TestTypeParentInfo] c ON c.[Id] = b.[ParentId]", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .InnerJoin(a => a.TestTypeInfoGuid == b.Guid) + .InnerJoin(a => a.TypeGuid == b.Guid) .InnerJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] b ON a.[TestTypeInfoGuid] = b.[Guid] INNER JOIN [TestTypeParentInfo] c ON b.[ParentId] = c.[Id]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN [TestTypeInfo] b ON a.[TypeGuid] = b.[Guid] INNER JOIN [TestTypeParentInfo] c ON b.[ParentId] = c.[Id]", sql); query2.ToList(); //������϶����㲻�� - query = select.InnerJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid"); + query = select.InnerJoin("TestTypeInfo b on b.Guid = a.TypeGuid"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN TestTypeInfo b on b.Guid = a.TypeGuid", sql); query.ToList(); - query = select.InnerJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = @bname", new { bname = "xxx" }); + query = select.InnerJoin("TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = @bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = @bname", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a INNER JOIN TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = @bname", sql); query.ToList(); } [Fact] public void RightJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.RightJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TypeGuid]", sql); query.ToList(); - query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.RightJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid] AND a__Type.[Name] = 'xxx'", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TypeGuid] AND a__Type.[Name] = 'xxx'", sql); query.ToList(); - query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.RightJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeParentInfo] a__Type__Parent ON 1 = 1 RIGHT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid] AND a__Type.[Name] = 'xxx' WHERE (a__Type__Parent.[Id] = 10)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeParentInfo] a__Type__Parent ON 1 = 1 RIGHT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TypeGuid] AND a__Type.[Name] = 'xxx' WHERE (a__Type__Parent.[Id] = 10)", sql); query.ToList(); //���û�е������� - query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.RightJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TestTypeInfoGuid]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TypeGuid]", sql); query.ToList(); - query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.RightJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TestTypeInfoGuid] AND b.[Name] = 'xxx'", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TypeGuid] AND b.[Name] = 'xxx'", sql); query.ToList(); - query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.RightJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeParentInfo] b__Parent ON 1 = 1 RIGHT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TestTypeInfoGuid] AND b.[Name] = 'xxx' WHERE (b__Parent.[Id] = 10)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a LEFT JOIN [TestTypeParentInfo] b__Parent ON 1 = 1 RIGHT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TypeGuid] AND b.[Name] = 'xxx' WHERE (b__Parent.[Id] = 10)", sql); query.ToList(); //������� query = select - .RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .RightJoin(a => a.Type.Guid == a.TypeGuid) .RightJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid] RIGHT JOIN [TestTypeParentInfo] a__Type__Parent ON a__Type__Parent.[Id] = a__Type.[ParentId]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] a__Type ON a__Type.[Guid] = a.[TypeGuid] RIGHT JOIN [TestTypeParentInfo] a__Type__Parent ON a__Type__Parent.[Id] = a__Type.[ParentId]", sql); query.ToList(); query = select - .RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .RightJoin((a, b) => b.Guid == a.TypeGuid) .RightJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TestTypeInfoGuid] RIGHT JOIN [TestTypeParentInfo] c ON c.[Id] = b.[ParentId]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] b ON b.[Guid] = a.[TypeGuid] RIGHT JOIN [TestTypeParentInfo] c ON c.[Id] = b.[ParentId]", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .RightJoin(a => a.TestTypeInfoGuid == b.Guid) + .RightJoin(a => a.TypeGuid == b.Guid) .RightJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] b ON a.[TestTypeInfoGuid] = b.[Guid] RIGHT JOIN [TestTypeParentInfo] c ON b.[ParentId] = c.[Id]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN [TestTypeInfo] b ON a.[TypeGuid] = b.[Guid] RIGHT JOIN [TestTypeParentInfo] c ON b.[ParentId] = c.[Id]", sql); query2.ToList(); //������϶����㲻�� - query = select.RightJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid"); + query = select.RightJoin("TestTypeInfo b on b.Guid = a.TypeGuid"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN TestTypeInfo b on b.Guid = a.TypeGuid", sql); query.ToList(); - query = select.RightJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = @bname", new { bname = "xxx" }); + query = select.RightJoin("TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = @bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = @bname", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a RIGHT JOIN TestTypeInfo b on b.Guid = a.TypeGuid and b.Name = @bname", sql); query.ToList(); } @@ -331,48 +331,48 @@ namespace FreeSql.Tests.SqlServer { //����е�������a.Type��a.Type.Parent ���ǵ������� var query = select.Where(a => a.Id == 10); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.[Id] = 10)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.[Id] = 10)", sql); query.ToList(); query = select.Where(a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.[Id] = 10 AND a.[Id] > 10 OR a.[Clicks] > 100)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.[Id] = 10 AND a.[Id] > 10 OR a.[Clicks] > 100)", sql); query.ToList(); query = select.Where(a => a.Id == 10).Where(a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.[Id] = 10) AND (a.[Clicks] > 100)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.[Id] = 10) AND (a.[Clicks] > 100)", sql); query.ToList(); query = select.Where(a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle')", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle')", sql); query.ToList(); - query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle' AND a__Type.[Guid] = a.[TestTypeInfoGuid])", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle' AND a__Type.[Guid] = a.[TypeGuid])", sql); query.ToList(); query = select.Where(a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type, [TestTypeParentInfo] a__Type__Parent WHERE (a__Type__Parent.[Name] = 'tparent')", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type, [TestTypeParentInfo] a__Type__Parent WHERE (a__Type__Parent.[Name] = 'tparent')", sql); query.ToList(); //���û�е������ԣ��򵥶������ - query = select.Where((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "typeTitle"); + query = select.Where((a, b) => b.Guid == a.TypeGuid && b.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] b WHERE (b.[Guid] = a.[TestTypeInfoGuid] AND b.[Name] = 'typeTitle')", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] b WHERE (b.[Guid] = a.[TypeGuid] AND b.[Name] = 'typeTitle')", sql); query.ToList(); - query = select.Where((a, b) => b.Name == "typeTitle" && b.Guid == a.TestTypeInfoGuid); + query = select.Where((a, b) => b.Name == "typeTitle" && b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] b WHERE (b.[Name] = 'typeTitle' AND b.[Guid] = a.[TestTypeInfoGuid])", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] b WHERE (b.[Name] = 'typeTitle' AND b.[Guid] = a.[TypeGuid])", sql); query.ToList(); query = select.Where((a, b, c) => c.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeParentInfo] c WHERE (c.[Name] = 'tparent')", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeParentInfo] c WHERE (c.[Name] = 'tparent')", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -380,13 +380,13 @@ namespace FreeSql.Tests.SqlServer { .Where(a => a.Id == 10 && c.Name == "xxx") .Where(a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeParentInfo] c, [TestTypeInfo] b WHERE (a.[Id] = 10 AND c.[Name] = 'xxx') AND (b.[ParentId] = 20)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeParentInfo] c, [TestTypeInfo] b WHERE (a.[Id] = 10 AND c.[Name] = 'xxx') AND (b.[ParentId] = 20)", sql); query2.ToList(); //������϶����㲻�� query = select.Where("a.clicks > 100 and a.id = @id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.clicks > 100 and a.id = @id)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.clicks > 100 and a.id = @id)", sql); query.ToList(); } [Fact] @@ -394,32 +394,32 @@ namespace FreeSql.Tests.SqlServer { //����е�������a.Type��a.Type.Parent ���ǵ������� var query = select.WhereIf(true, a => a.Id == 10); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.[Id] = 10)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.[Id] = 10)", sql); query.ToList(); query = select.WhereIf(true, a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.[Id] = 10 AND a.[Id] > 10 OR a.[Clicks] > 100)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.[Id] = 10 AND a.[Id] > 10 OR a.[Clicks] > 100)", sql); query.ToList(); query = select.WhereIf(true, a => a.Id == 10).WhereIf(true, a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.[Id] = 10) AND (a.[Clicks] > 100)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.[Id] = 10) AND (a.[Clicks] > 100)", sql); query.ToList(); query = select.WhereIf(true, a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle')", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle')", sql); query.ToList(); - query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle' AND a__Type.[Guid] = a.[TestTypeInfoGuid])", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle' AND a__Type.[Guid] = a.[TypeGuid])", sql); query.ToList(); query = select.WhereIf(true, a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type, [TestTypeParentInfo] a__Type__Parent WHERE (a__Type__Parent.[Name] = 'tparent')", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type, [TestTypeParentInfo] a__Type__Parent WHERE (a__Type__Parent.[Name] = 'tparent')", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -427,13 +427,13 @@ namespace FreeSql.Tests.SqlServer { .WhereIf(true, a => a.Id == 10 && c.Name == "xxx") .WhereIf(true, a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeParentInfo] c, [TestTypeInfo] b WHERE (a.[Id] = 10 AND c.[Name] = 'xxx') AND (b.[ParentId] = 20)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeParentInfo] c, [TestTypeInfo] b WHERE (a.[Id] = 10 AND c.[Name] = 'xxx') AND (b.[ParentId] = 20)", sql); query2.ToList(); //������϶����㲻�� query = select.WhereIf(true, "a.clicks > 100 and a.id = @id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.clicks > 100 and a.id = @id)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a WHERE (a.clicks > 100 and a.id = @id)", sql); query.ToList(); // ==========================================WhereIf(false) @@ -441,32 +441,32 @@ namespace FreeSql.Tests.SqlServer { //����е�������a.Type��a.Type.Parent ���ǵ������� query = select.WhereIf(false, a => a.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); query.ToList(); query = select.WhereIf(false, a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); query.ToList(); query = select.WhereIf(false, a => a.Id == 10).WhereIf(false, a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); query.ToList(); query = select.WhereIf(false, a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); query.ToList(); - query = select.WhereIf(false, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.WhereIf(false, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); query.ToList(); query = select.WhereIf(false, a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -474,13 +474,13 @@ namespace FreeSql.Tests.SqlServer { .WhereIf(false, a => a.Id == 10 && c.Name == "xxx") .WhereIf(false, a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); query2.ToList(); //������϶����㲻�� query = select.WhereIf(false, "a.clicks > 100 and a.id = @id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a", sql); query.ToList(); } [Fact] @@ -555,59 +555,59 @@ namespace FreeSql.Tests.SqlServer { }; //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid).AsTable(tableRule); + var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).AsTable(tableRule); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] a__Type ON a__Type.[Guid] = a.[TypeGuid]", sql); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").AsTable(tableRule); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid] AND a__Type.[Name] = 'xxx'", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] a__Type ON a__Type.[Guid] = a.[TypeGuid] AND a__Type.[Name] = 'xxx'", sql); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeParentInfoAsTable] a__Type__Parent ON 1 = 1 LEFT JOIN [TestTypeInfoAsTable2] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid] AND a__Type.[Name] = 'xxx' WHERE (a__Type__Parent.[Id] = 10)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeParentInfoAsTable] a__Type__Parent ON 1 = 1 LEFT JOIN [TestTypeInfoAsTable2] a__Type ON a__Type.[Guid] = a.[TypeGuid] AND a__Type.[Name] = 'xxx' WHERE (a__Type__Parent.[Id] = 10)", sql); //���û�е������� - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid).AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] b ON b.[Guid] = a.[TestTypeInfoGuid]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] b ON b.[Guid] = a.[TypeGuid]", sql); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] b ON b.[Guid] = a.[TestTypeInfoGuid] AND b.[Name] = 'xxx'", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] b ON b.[Guid] = a.[TypeGuid] AND b.[Name] = 'xxx'", sql); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeParentInfoAsTable] b__Parent ON 1 = 1 LEFT JOIN [TestTypeInfoAsTable2] b ON b.[Guid] = a.[TestTypeInfoGuid] AND b.[Name] = 'xxx' WHERE (b__Parent.[Id] = 10)", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeParentInfoAsTable] b__Parent ON 1 = 1 LEFT JOIN [TestTypeInfoAsTable2] b ON b.[Guid] = a.[TypeGuid] AND b.[Name] = 'xxx' WHERE (b__Parent.[Id] = 10)", sql); //������� query = select - .LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .LeftJoin(a => a.Type.Guid == a.TypeGuid) .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] a__Type ON a__Type.[Guid] = a.[TestTypeInfoGuid] LEFT JOIN [TestTypeParentInfoAsTable] a__Type__Parent ON a__Type__Parent.[Id] = a__Type.[ParentId]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] a__Type ON a__Type.[Guid] = a.[TypeGuid] LEFT JOIN [TestTypeParentInfoAsTable] a__Type__Parent ON a__Type__Parent.[Id] = a__Type.[ParentId]", sql); query = select - .LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .LeftJoin((a, b) => b.Guid == a.TypeGuid) .LeftJoin((a, c) => c.Id == a.Type.ParentId).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] b ON b.[Guid] = a.[TestTypeInfoGuid] LEFT JOIN [TestTypeParentInfoAsTable] c ON c.[Id] = b.[ParentId]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] b ON b.[Guid] = a.[TypeGuid] LEFT JOIN [TestTypeParentInfoAsTable] c ON c.[Id] = b.[ParentId]", sql); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id)).AsTable(tableRule); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] b ON a.[TestTypeInfoGuid] = b.[Guid] LEFT JOIN [TestTypeParentInfoAsTable] c ON b.[ParentId] = c.[Id]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfoAsTable2] b ON a.[TypeGuid] = b.[Guid] LEFT JOIN [TestTypeParentInfoAsTable] c ON b.[ParentId] = c.[Id]", sql); //������϶����㲻�� - query = select.LeftJoin("[TestTypeInfo] b on b.[Guid] = a.[TestTypeInfoGuid]").AsTable(tableRule); + query = select.LeftJoin("[TestTypeInfo] b on b.[Guid] = a.[TypeGuid]").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfo] b on b.[Guid] = a.[TestTypeInfoGuid]", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfo] b on b.[Guid] = a.[TypeGuid]", sql); - query = select.LeftJoin("[TestTypeInfo] b on b.[Guid] = a.[TestTypeInfoGuid] and b.[Name] = @bname", new { bname = "xxx" }).AsTable(tableRule); + query = select.LeftJoin("[TestTypeInfo] b on b.[Guid] = a.[TypeGuid] and b.[Name] = @bname", new { bname = "xxx" }).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfo] b on b.[Guid] = a.[TestTypeInfoGuid] and b.[Name] = @bname", sql); + Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TypeGuid], a.[Title], a.[CreateTime] FROM [tb_topic22AsTable1] a LEFT JOIN [TestTypeInfo] b on b.[Guid] = a.[TypeGuid] and b.[Name] = @bname", sql); } } } diff --git a/FreeSql.Tests/SqlServer/Curd/SqlServerUpdateTest.cs b/FreeSql.Tests/SqlServer/Curd/SqlServerUpdateTest.cs index 13a8d996..03e7f3a4 100644 --- a/FreeSql.Tests/SqlServer/Curd/SqlServerUpdateTest.cs +++ b/FreeSql.Tests/SqlServer/Curd/SqlServerUpdateTest.cs @@ -22,7 +22,7 @@ namespace FreeSql.Tests.SqlServer { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int? Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -39,24 +39,24 @@ namespace FreeSql.Tests.SqlServer { [Fact] public void SetSource() { - var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).IgnoreColumns(a => a.TestTypeInfoGuid).ToSql().Replace("\r\n", ""); + var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).IgnoreColumns(a => a.TypeGuid).ToSql().Replace("\r\n", ""); Assert.Equal("UPDATE [tb_topic] SET [Clicks] = @p_0, [Title] = @p_1, [CreateTime] = @p_2 WHERE ([Id] = 1)", sql); var items = new List(); for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 }); - sql = update.SetSource(items).IgnoreColumns(a => a.TestTypeInfoGuid).ToSql().Replace("\r\n", ""); + sql = update.SetSource(items).IgnoreColumns(a => a.TypeGuid).ToSql().Replace("\r\n", ""); Assert.Equal("UPDATE [tb_topic] SET [Clicks] = CASE [Id] WHEN 1 THEN @p_0 WHEN 2 THEN @p_1 WHEN 3 THEN @p_2 WHEN 4 THEN @p_3 WHEN 5 THEN @p_4 WHEN 6 THEN @p_5 WHEN 7 THEN @p_6 WHEN 8 THEN @p_7 WHEN 9 THEN @p_8 WHEN 10 THEN @p_9 END, [Title] = CASE [Id] WHEN 1 THEN @p_10 WHEN 2 THEN @p_11 WHEN 3 THEN @p_12 WHEN 4 THEN @p_13 WHEN 5 THEN @p_14 WHEN 6 THEN @p_15 WHEN 7 THEN @p_16 WHEN 8 THEN @p_17 WHEN 9 THEN @p_18 WHEN 10 THEN @p_19 END, [CreateTime] = CASE [Id] WHEN 1 THEN @p_20 WHEN 2 THEN @p_21 WHEN 3 THEN @p_22 WHEN 4 THEN @p_23 WHEN 5 THEN @p_24 WHEN 6 THEN @p_25 WHEN 7 THEN @p_26 WHEN 8 THEN @p_27 WHEN 9 THEN @p_28 WHEN 10 THEN @p_29 END WHERE ([Id] IN (1,2,3,4,5,6,7,8,9,10))", sql); - sql = update.SetSource(items).IgnoreColumns(a => new { a.Clicks, a.CreateTime, a.TestTypeInfoGuid }).ToSql().Replace("\r\n", ""); + sql = update.SetSource(items).IgnoreColumns(a => new { a.Clicks, a.CreateTime, a.TypeGuid }).ToSql().Replace("\r\n", ""); Assert.Equal("UPDATE [tb_topic] SET [Title] = CASE [Id] WHEN 1 THEN @p_0 WHEN 2 THEN @p_1 WHEN 3 THEN @p_2 WHEN 4 THEN @p_3 WHEN 5 THEN @p_4 WHEN 6 THEN @p_5 WHEN 7 THEN @p_6 WHEN 8 THEN @p_7 WHEN 9 THEN @p_8 WHEN 10 THEN @p_9 END WHERE ([Id] IN (1,2,3,4,5,6,7,8,9,10))", sql); - sql = update.SetSource(items).IgnoreColumns(a => a.TestTypeInfoGuid).Set(a => a.CreateTime, new DateTime(2020,1,1)).ToSql().Replace("\r\n", ""); + sql = update.SetSource(items).IgnoreColumns(a => a.TypeGuid).Set(a => a.CreateTime, new DateTime(2020,1,1)).ToSql().Replace("\r\n", ""); Assert.Equal("UPDATE [tb_topic] SET [CreateTime] = @p_0 WHERE ([Id] IN (1,2,3,4,5,6,7,8,9,10))", sql); } [Fact] public void IgnoreColumns() { - var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).IgnoreColumns(a => new { a.Clicks, a.CreateTime, a.TestTypeInfoGuid }).ToSql().Replace("\r\n", ""); + var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).IgnoreColumns(a => new { a.Clicks, a.CreateTime, a.TypeGuid }).ToSql().Replace("\r\n", ""); Assert.Equal("UPDATE [tb_topic] SET [Title] = @p_0 WHERE ([Id] = 1)", sql); } [Fact] diff --git a/FreeSql.Tests/SqlServer/SqlServerExpression/ConvertTest.cs b/FreeSql.Tests/SqlServer/SqlServerExpression/ConvertTest.cs index 4ed584a2..6f1d84a6 100644 --- a/FreeSql.Tests/SqlServer/SqlServerExpression/ConvertTest.cs +++ b/FreeSql.Tests/SqlServer/SqlServerExpression/ConvertTest.cs @@ -23,7 +23,7 @@ namespace FreeSql.Tests.SqlServerExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } diff --git a/FreeSql.Tests/SqlServer/SqlServerExpression/DateTimeTest.cs b/FreeSql.Tests/SqlServer/SqlServerExpression/DateTimeTest.cs index 79f05449..248d5032 100644 --- a/FreeSql.Tests/SqlServer/SqlServerExpression/DateTimeTest.cs +++ b/FreeSql.Tests/SqlServer/SqlServerExpression/DateTimeTest.cs @@ -23,7 +23,7 @@ namespace FreeSql.Tests.SqlServerExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } diff --git a/FreeSql.Tests/SqlServer/SqlServerExpression/MathTest.cs b/FreeSql.Tests/SqlServer/SqlServerExpression/MathTest.cs index 6613dfe9..cab91615 100644 --- a/FreeSql.Tests/SqlServer/SqlServerExpression/MathTest.cs +++ b/FreeSql.Tests/SqlServer/SqlServerExpression/MathTest.cs @@ -23,7 +23,7 @@ namespace FreeSql.Tests.SqlServerExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } diff --git a/FreeSql.Tests/SqlServer/SqlServerExpression/StringTest.cs b/FreeSql.Tests/SqlServer/SqlServerExpression/StringTest.cs index 50f5c621..07d5fd61 100644 --- a/FreeSql.Tests/SqlServer/SqlServerExpression/StringTest.cs +++ b/FreeSql.Tests/SqlServer/SqlServerExpression/StringTest.cs @@ -23,7 +23,7 @@ namespace FreeSql.Tests.SqlServerExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } diff --git a/FreeSql.Tests/SqlServer/SqlServerExpression/TimeSpanTest.cs b/FreeSql.Tests/SqlServer/SqlServerExpression/TimeSpanTest.cs index e9bff692..7490b5ea 100644 --- a/FreeSql.Tests/SqlServer/SqlServerExpression/TimeSpanTest.cs +++ b/FreeSql.Tests/SqlServer/SqlServerExpression/TimeSpanTest.cs @@ -23,7 +23,7 @@ namespace FreeSql.Tests.SqlServerExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } diff --git a/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs b/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs index 3a4e9bdd..547b624c 100644 --- a/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs +++ b/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.Sqlite { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -113,7 +113,7 @@ namespace FreeSql.Tests.Sqlite { var sql2222Tolist = sql2222.ToList(); var collectionSelect = select.Where(a => - a.Type.Guid == a.TestTypeInfoGuid && + a.Type.Guid == a.TypeGuid && a.Type.Parent.Id == a.Type.ParentId && a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any(b => b.ParentId == a.Type.Parent.Id) ); @@ -144,216 +144,216 @@ namespace FreeSql.Tests.Sqlite { public void From() { //������� var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id) ); var sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON a.\"TestTypeInfoGuid\" = b.\"Guid\" LEFT JOIN \"TestTypeParentInfo\" c ON b.\"ParentId\" = c.\"Id\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON a.\"TypeGuid\" = b.\"Guid\" LEFT JOIN \"TestTypeParentInfo\" c ON b.\"ParentId\" = c.\"Id\"", sql); query2.ToList(); } [Fact] public void LeftJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\" AND a__Type.\"Name\" = 'xxx'", sql); query.ToList(); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" a__Type__Parent ON 1 = 1 LEFT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx' WHERE (a__Type__Parent.\"Id\" = 10)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" a__Type__Parent ON 1 = 1 LEFT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\" AND a__Type.\"Name\" = 'xxx' WHERE (a__Type__Parent.\"Id\" = 10)", sql); query.ToList(); //���û�е������� - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TypeGuid\" AND b.\"Name\" = 'xxx'", sql); query.ToList(); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" b__Parent ON 1 = 1 LEFT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx' WHERE (b__Parent.\"Id\" = 10)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" b__Parent ON 1 = 1 LEFT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TypeGuid\" AND b.\"Name\" = 'xxx' WHERE (b__Parent.\"Id\" = 10)", sql); query.ToList(); //������� query = select - .LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .LeftJoin(a => a.Type.Guid == a.TypeGuid) .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" LEFT JOIN \"TestTypeParentInfo\" a__Type__Parent ON a__Type__Parent.\"Id\" = a__Type.\"ParentId\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\" LEFT JOIN \"TestTypeParentInfo\" a__Type__Parent ON a__Type__Parent.\"Id\" = a__Type.\"ParentId\"", sql); query.ToList(); query = select - .LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .LeftJoin((a, b) => b.Guid == a.TypeGuid) .LeftJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" LEFT JOIN \"TestTypeParentInfo\" c ON c.\"Id\" = b.\"ParentId\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TypeGuid\" LEFT JOIN \"TestTypeParentInfo\" c ON c.\"Id\" = b.\"ParentId\"", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON a.\"TestTypeInfoGuid\" = b.\"Guid\" LEFT JOIN \"TestTypeParentInfo\" c ON b.\"ParentId\" = c.\"Id\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON a.\"TypeGuid\" = b.\"Guid\" LEFT JOIN \"TestTypeParentInfo\" c ON b.\"ParentId\" = c.\"Id\"", sql); query2.ToList(); //������϶����㲻�� - query = select.LeftJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\""); + query = select.LeftJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\""); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.LeftJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = @bname", new { bname = "xxx" }); + query = select.LeftJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\" and b.\"Name\" = @bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = @bname", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\" and b.\"Name\" = @bname", sql); query.ToList(); } [Fact] public void InnerJoin() { //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + var query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\" AND a__Type.\"Name\" = 'xxx'", sql); query.ToList(); - query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" a__Type__Parent ON 1 = 1 INNER JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx' WHERE (a__Type__Parent.\"Id\" = 10)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" a__Type__Parent ON 1 = 1 INNER JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\" AND a__Type.\"Name\" = 'xxx' WHERE (a__Type__Parent.\"Id\" = 10)", sql); query.ToList(); //���û�е������� - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TypeGuid\" AND b.\"Name\" = 'xxx'", sql); query.ToList(); - query = select.InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + query = select.InnerJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" b__Parent ON 1 = 1 INNER JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx' WHERE (b__Parent.\"Id\" = 10)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" b__Parent ON 1 = 1 INNER JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TypeGuid\" AND b.\"Name\" = 'xxx' WHERE (b__Parent.\"Id\" = 10)", sql); query.ToList(); //������� query = select - .InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .InnerJoin(a => a.Type.Guid == a.TypeGuid) .InnerJoin(a => a.Type.Parent.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" INNER JOIN \"TestTypeParentInfo\" a__Type__Parent ON a__Type__Parent.\"Id\" = a__Type.\"ParentId\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\" INNER JOIN \"TestTypeParentInfo\" a__Type__Parent ON a__Type__Parent.\"Id\" = a__Type.\"ParentId\"", sql); query.ToList(); query = select - .InnerJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .InnerJoin((a, b) => b.Guid == a.TypeGuid) .InnerJoin((a, c) => c.Id == a.Type.ParentId); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" INNER JOIN \"TestTypeParentInfo\" c ON c.\"Id\" = b.\"ParentId\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TypeGuid\" INNER JOIN \"TestTypeParentInfo\" c ON c.\"Id\" = b.\"ParentId\"", sql); query.ToList(); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .InnerJoin(a => a.TestTypeInfoGuid == b.Guid) + .InnerJoin(a => a.TypeGuid == b.Guid) .InnerJoin(a => b.ParentId == c.Id)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b ON a.\"TestTypeInfoGuid\" = b.\"Guid\" INNER JOIN \"TestTypeParentInfo\" c ON b.\"ParentId\" = c.\"Id\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b ON a.\"TypeGuid\" = b.\"Guid\" INNER JOIN \"TestTypeParentInfo\" c ON b.\"ParentId\" = c.\"Id\"", sql); query2.ToList(); //������϶����㲻�� - query = select.InnerJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\""); + query = select.InnerJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\""); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\"", sql); query.ToList(); - query = select.InnerJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = @bname", new { bname = "xxx" }); + query = select.InnerJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\" and b.\"Name\" = @bname", new { bname = "xxx" }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = @bname", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\" and b.\"Name\" = @bname", sql); query.ToList(); } [Fact] public void RightJoin() { ////����е�������a.Type��a.Type.Parent ���ǵ������� - //var query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid); + //var query = select.RightJoin(a => a.Type.Guid == a.TypeGuid); //var sql = query.ToSql().Replace("\r\n", ""); - //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\"", sql); + //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\"", sql); //query.ToList(); - //query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx"); + //query = select.RightJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); //sql = query.ToSql().Replace("\r\n", ""); - //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx'", sql); + //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\" AND a__Type.\"Name\" = 'xxx'", sql); //query.ToList(); - //query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + //query = select.RightJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); //sql = query.ToSql().Replace("\r\n", ""); - //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" a__Type__Parent ON 1 = 1 RIGHT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx' WHERE (a__Type__Parent.\"Id\" = 10)", sql); + //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" a__Type__Parent ON 1 = 1 RIGHT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\" AND a__Type.\"Name\" = 'xxx' WHERE (a__Type__Parent.\"Id\" = 10)", sql); //query.ToList(); ////���û�е������� - //query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid); + //query = select.RightJoin((a, b) => b.Guid == a.TypeGuid); //sql = query.ToSql().Replace("\r\n", ""); - //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql); + //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TypeGuid\"", sql); //query.ToList(); - //query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx"); + //query = select.RightJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); //sql = query.ToSql().Replace("\r\n", ""); - //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx'", sql); + //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TypeGuid\" AND b.\"Name\" = 'xxx'", sql); //query.ToList(); - //query = select.RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); + //query = select.RightJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10); //sql = query.ToSql().Replace("\r\n", ""); - //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" b__Parent ON 1 = 1 RIGHT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx' WHERE (b__Parent.\"Id\" = 10)", sql); + //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" b__Parent ON 1 = 1 RIGHT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TypeGuid\" AND b.\"Name\" = 'xxx' WHERE (b__Parent.\"Id\" = 10)", sql); //query.ToList(); ////������� //query = select - // .RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + // .RightJoin(a => a.Type.Guid == a.TypeGuid) // .RightJoin(a => a.Type.Parent.Id == a.Type.ParentId); //sql = query.ToSql().Replace("\r\n", ""); - //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" RIGHT JOIN \"TestTypeParentInfo\" a__Type__Parent ON a__Type__Parent.\"Id\" = a__Type.\"ParentId\"", sql); + //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\" RIGHT JOIN \"TestTypeParentInfo\" a__Type__Parent ON a__Type__Parent.\"Id\" = a__Type.\"ParentId\"", sql); //query.ToList(); //query = select - // .RightJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + // .RightJoin((a, b) => b.Guid == a.TypeGuid) // .RightJoin((a, c) => c.Id == a.Type.ParentId); //sql = query.ToSql().Replace("\r\n", ""); - //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" RIGHT JOIN \"TestTypeParentInfo\" c ON c.\"Id\" = b.\"ParentId\"", sql); + //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TypeGuid\" RIGHT JOIN \"TestTypeParentInfo\" c ON c.\"Id\" = b.\"ParentId\"", sql); //query.ToList(); ////���û�е�������b��c������ϵ //var query2 = select.From((s, b, c) => s - // .RightJoin(a => a.TestTypeInfoGuid == b.Guid) + // .RightJoin(a => a.TypeGuid == b.Guid) // .RightJoin(a => b.ParentId == c.Id)); //sql = query2.ToSql().Replace("\r\n", ""); - //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b ON a.\"TestTypeInfoGuid\" = b.\"Guid\" RIGHT JOIN \"TestTypeParentInfo\" c ON b.\"ParentId\" = c.\"Id\"", sql); + //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b ON a.\"TypeGuid\" = b.\"Guid\" RIGHT JOIN \"TestTypeParentInfo\" c ON b.\"ParentId\" = c.\"Id\"", sql); //query2.ToList(); ////������϶����㲻�� - //query = select.RightJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\""); + //query = select.RightJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\""); //sql = query.ToSql().Replace("\r\n", ""); - //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql); + //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\"", sql); //query.ToList(); - //query = select.RightJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = @bname", new { bname = "xxx" }); + //query = select.RightJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\" and b.\"Name\" = @bname", new { bname = "xxx" }); //sql = query.ToSql().Replace("\r\n", ""); - //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = @bname", sql); + //Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\" and b.\"Name\" = @bname", sql); //query.ToList(); } @@ -362,48 +362,48 @@ namespace FreeSql.Tests.Sqlite { //����е�������a.Type��a.Type.Parent ���ǵ������� var query = select.Where(a => a.Id == 10); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10)", sql); query.ToList(); query = select.Where(a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10 AND a.\"Id\" > 10 OR a.\"Clicks\" > 100)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10 AND a.\"Id\" > 10 OR a.\"Clicks\" > 100)", sql); query.ToList(); query = select.Where(a => a.Id == 10).Where(a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10) AND (a.\"Clicks\" > 100)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10) AND (a.\"Clicks\" > 100)", sql); query.ToList(); query = select.Where(a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql); query.ToList(); - query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TestTypeInfoGuid\")", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TypeGuid\")", sql); query.ToList(); query = select.Where(a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql); query.ToList(); //���û�е������ԣ��򵥶������ - query = select.Where((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "typeTitle"); + query = select.Where((a, b) => b.Guid == a.TypeGuid && b.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'typeTitle')", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Guid\" = a.\"TypeGuid\" AND b.\"Name\" = 'typeTitle')", sql); query.ToList(); - query = select.Where((a, b) => b.Name == "typeTitle" && b.Guid == a.TestTypeInfoGuid); + query = select.Where((a, b) => b.Name == "typeTitle" && b.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Name\" = 'typeTitle' AND b.\"Guid\" = a.\"TestTypeInfoGuid\")", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Name\" = 'typeTitle' AND b.\"Guid\" = a.\"TypeGuid\")", sql); query.ToList(); query = select.Where((a, b, c) => c.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c WHERE (c.\"Name\" = 'tparent')", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c WHERE (c.\"Name\" = 'tparent')", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -411,13 +411,13 @@ namespace FreeSql.Tests.Sqlite { .Where(a => a.Id == 10 && c.Name == "xxx") .Where(a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql); query2.ToList(); //������϶����㲻�� query = select.Where("a.\"Clicks\" > 100 and a.\"Id\" = @id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Clicks\" > 100 and a.\"Id\" = @id)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Clicks\" > 100 and a.\"Id\" = @id)", sql); query.ToList(); } [Fact] @@ -425,32 +425,32 @@ namespace FreeSql.Tests.Sqlite { //����е�������a.Type��a.Type.Parent ���ǵ������� var query = select.WhereIf(true, a => a.Id == 10); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10)", sql); query.ToList(); query = select.WhereIf(true, a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10 AND a.\"Id\" > 10 OR a.\"Clicks\" > 100)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10 AND a.\"Id\" > 10 OR a.\"Clicks\" > 100)", sql); query.ToList(); query = select.WhereIf(true, a => a.Id == 10).WhereIf(true, a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10) AND (a.\"Clicks\" > 100)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10) AND (a.\"Clicks\" > 100)", sql); query.ToList(); query = select.WhereIf(true, a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql); query.ToList(); - query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TestTypeInfoGuid\")", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TypeGuid\")", sql); query.ToList(); query = select.WhereIf(true, a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -458,13 +458,13 @@ namespace FreeSql.Tests.Sqlite { .WhereIf(true, a => a.Id == 10 && c.Name == "xxx") .WhereIf(true, a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql); query2.ToList(); //������϶����㲻�� query = select.WhereIf(true, "a.\"Clicks\" > 100 and a.\"Id\" = @id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Clicks\" > 100 and a.\"Id\" = @id)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Clicks\" > 100 and a.\"Id\" = @id)", sql); query.ToList(); // ==========================================WhereIf(false) @@ -472,32 +472,32 @@ namespace FreeSql.Tests.Sqlite { //����е�������a.Type��a.Type.Parent ���ǵ������� query = select.WhereIf(false, a => a.Id == 10); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); query.ToList(); query = select.WhereIf(false, a => a.Id == 10 && a.Id > 10 || a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); query.ToList(); query = select.WhereIf(false, a => a.Id == 10).WhereIf(false, a => a.Clicks > 100); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); query.ToList(); query = select.WhereIf(false, a => a.Type.Name == "typeTitle"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); query.ToList(); - query = select.WhereIf(false, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid); + query = select.WhereIf(false, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); query.ToList(); query = select.WhereIf(false, a => a.Type.Parent.Name == "tparent"); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); query.ToList(); //����һ�� From ��Ķ������ @@ -505,13 +505,13 @@ namespace FreeSql.Tests.Sqlite { .WhereIf(false, a => a.Id == 10 && c.Name == "xxx") .WhereIf(false, a => b.ParentId == 20)); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); query2.ToList(); //������϶����㲻�� query = select.WhereIf(false, "a.\"Clicks\" > 100 and a.\"Id\" = @id", new { id = 10 }); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql); query.ToList(); } [Fact] @@ -586,13 +586,13 @@ namespace FreeSql.Tests.Sqlite { //reposTopic.Delete(Guid.Empty); //reposTopic.Find(Guid.Empty); - //reposTopic.Update(new Topic { TestTypeInfoGuid = 1 }); + //reposTopic.Update(new Topic { TypeGuid = 1 }); var sql11 = reposTopic.Select .FromRepository(reposType) .From((s,b,c) => s) - .LeftJoin(a => a.TestTypeInfoGuid == a.Type.Guid) + .LeftJoin(a => a.TypeGuid == a.Type.Guid) .ToSql(); @@ -604,59 +604,59 @@ namespace FreeSql.Tests.Sqlite { }; //����е�������a.Type��a.Type.Parent ���ǵ������� - var query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid).AsTable(tableRule); + var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).AsTable(tableRule); var sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\"", sql); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").AsTable(tableRule); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\" AND a__Type.\"Name\" = 'xxx'", sql); - query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); + query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeParentInfoAsTable\" a__Type__Parent ON 1 = 1 LEFT JOIN \"TestTypeInfoAsTable2\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx' WHERE (a__Type__Parent.\"Id\" = 10)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeParentInfoAsTable\" a__Type__Parent ON 1 = 1 LEFT JOIN \"TestTypeInfoAsTable2\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\" AND a__Type.\"Name\" = 'xxx' WHERE (a__Type__Parent.\"Id\" = 10)", sql); //���û�е������� - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid).AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" b ON b.\"Guid\" = a.\"TypeGuid\"", sql); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx'", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" b ON b.\"Guid\" = a.\"TypeGuid\" AND b.\"Name\" = 'xxx'", sql); - query = select.LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); + query = select.LeftJoin((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeParentInfoAsTable\" b__Parent ON 1 = 1 LEFT JOIN \"TestTypeInfoAsTable2\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx' WHERE (b__Parent.\"Id\" = 10)", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeParentInfoAsTable\" b__Parent ON 1 = 1 LEFT JOIN \"TestTypeInfoAsTable2\" b ON b.\"Guid\" = a.\"TypeGuid\" AND b.\"Name\" = 'xxx' WHERE (b__Parent.\"Id\" = 10)", sql); //������� query = select - .LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid) + .LeftJoin(a => a.Type.Guid == a.TypeGuid) .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" LEFT JOIN \"TestTypeParentInfoAsTable\" a__Type__Parent ON a__Type__Parent.\"Id\" = a__Type.\"ParentId\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" a__Type ON a__Type.\"Guid\" = a.\"TypeGuid\" LEFT JOIN \"TestTypeParentInfoAsTable\" a__Type__Parent ON a__Type__Parent.\"Id\" = a__Type.\"ParentId\"", sql); query = select - .LeftJoin((a, b) => b.Guid == a.TestTypeInfoGuid) + .LeftJoin((a, b) => b.Guid == a.TypeGuid) .LeftJoin((a, c) => c.Id == a.Type.ParentId).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" LEFT JOIN \"TestTypeParentInfoAsTable\" c ON c.\"Id\" = b.\"ParentId\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" b ON b.\"Guid\" = a.\"TypeGuid\" LEFT JOIN \"TestTypeParentInfoAsTable\" c ON c.\"Id\" = b.\"ParentId\"", sql); //���û�е�������b��c������ϵ var query2 = select.From((s, b, c) => s - .LeftJoin(a => a.TestTypeInfoGuid == b.Guid) + .LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => b.ParentId == c.Id)).AsTable(tableRule); sql = query2.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" b ON a.\"TestTypeInfoGuid\" = b.\"Guid\" LEFT JOIN \"TestTypeParentInfoAsTable\" c ON b.\"ParentId\" = c.\"Id\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfoAsTable2\" b ON a.\"TypeGuid\" = b.\"Guid\" LEFT JOIN \"TestTypeParentInfoAsTable\" c ON b.\"ParentId\" = c.\"Id\"", sql); //������϶����㲻�� - query = select.LeftJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\"").AsTable(tableRule); + query = select.LeftJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\"").AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\"", sql); - query = select.LeftJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = @bname", new { bname = "xxx" }).AsTable(tableRule); + query = select.LeftJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\" and b.\"Name\" = @bname", new { bname = "xxx" }).AsTable(tableRule); sql = query.ToSql().Replace("\r\n", ""); - Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = @bname", sql); + Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TypeGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22AsTable1\" a LEFT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TypeGuid\" and b.\"Name\" = @bname", sql); } } } diff --git a/FreeSql.Tests/Sqlite/Curd/SqliteUpdateTest.cs b/FreeSql.Tests/Sqlite/Curd/SqliteUpdateTest.cs index 19d450fb..18e5c891 100644 --- a/FreeSql.Tests/Sqlite/Curd/SqliteUpdateTest.cs +++ b/FreeSql.Tests/Sqlite/Curd/SqliteUpdateTest.cs @@ -12,7 +12,7 @@ namespace FreeSql.Tests.Sqlite { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int? Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -29,24 +29,24 @@ namespace FreeSql.Tests.Sqlite { [Fact] public void SetSource() { - var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).IgnoreColumns(a => a.TestTypeInfoGuid).ToSql().Replace("\r\n", ""); + var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).IgnoreColumns(a => a.TypeGuid).ToSql().Replace("\r\n", ""); Assert.Equal("UPDATE \"tb_topic\" SET \"Clicks\" = @p_0, \"Title\" = @p_1, \"CreateTime\" = @p_2 WHERE (\"Id\" = 1)", sql); var items = new List(); for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 }); - sql = update.SetSource(items).IgnoreColumns(a => a.TestTypeInfoGuid).ToSql().Replace("\r\n", ""); + sql = update.SetSource(items).IgnoreColumns(a => a.TypeGuid).ToSql().Replace("\r\n", ""); Assert.Equal("UPDATE \"tb_topic\" SET \"Clicks\" = CASE \"Id\" WHEN 1 THEN @p_0 WHEN 2 THEN @p_1 WHEN 3 THEN @p_2 WHEN 4 THEN @p_3 WHEN 5 THEN @p_4 WHEN 6 THEN @p_5 WHEN 7 THEN @p_6 WHEN 8 THEN @p_7 WHEN 9 THEN @p_8 WHEN 10 THEN @p_9 END, \"Title\" = CASE \"Id\" WHEN 1 THEN @p_10 WHEN 2 THEN @p_11 WHEN 3 THEN @p_12 WHEN 4 THEN @p_13 WHEN 5 THEN @p_14 WHEN 6 THEN @p_15 WHEN 7 THEN @p_16 WHEN 8 THEN @p_17 WHEN 9 THEN @p_18 WHEN 10 THEN @p_19 END, \"CreateTime\" = CASE \"Id\" WHEN 1 THEN @p_20 WHEN 2 THEN @p_21 WHEN 3 THEN @p_22 WHEN 4 THEN @p_23 WHEN 5 THEN @p_24 WHEN 6 THEN @p_25 WHEN 7 THEN @p_26 WHEN 8 THEN @p_27 WHEN 9 THEN @p_28 WHEN 10 THEN @p_29 END WHERE (\"Id\" IN (1,2,3,4,5,6,7,8,9,10))", sql); - sql = update.SetSource(items).IgnoreColumns(a => new { a.Clicks, a.CreateTime, a.TestTypeInfoGuid }).ToSql().Replace("\r\n", ""); + sql = update.SetSource(items).IgnoreColumns(a => new { a.Clicks, a.CreateTime, a.TypeGuid }).ToSql().Replace("\r\n", ""); Assert.Equal("UPDATE \"tb_topic\" SET \"Title\" = CASE \"Id\" WHEN 1 THEN @p_0 WHEN 2 THEN @p_1 WHEN 3 THEN @p_2 WHEN 4 THEN @p_3 WHEN 5 THEN @p_4 WHEN 6 THEN @p_5 WHEN 7 THEN @p_6 WHEN 8 THEN @p_7 WHEN 9 THEN @p_8 WHEN 10 THEN @p_9 END WHERE (\"Id\" IN (1,2,3,4,5,6,7,8,9,10))", sql); - sql = update.SetSource(items).IgnoreColumns(a => a.TestTypeInfoGuid).Set(a => a.CreateTime, new DateTime(2020,1,1)).ToSql().Replace("\r\n", ""); + sql = update.SetSource(items).IgnoreColumns(a => a.TypeGuid).Set(a => a.CreateTime, new DateTime(2020,1,1)).ToSql().Replace("\r\n", ""); Assert.Equal("UPDATE \"tb_topic\" SET \"CreateTime\" = @p_0 WHERE (\"Id\" IN (1,2,3,4,5,6,7,8,9,10))", sql); } [Fact] public void IgnoreColumns() { - var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).IgnoreColumns(a => new { a.Clicks, a.CreateTime, a.TestTypeInfoGuid }).ToSql().Replace("\r\n", ""); + var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).IgnoreColumns(a => new { a.Clicks, a.CreateTime, a.TypeGuid }).ToSql().Replace("\r\n", ""); Assert.Equal("UPDATE \"tb_topic\" SET \"Title\" = @p_0 WHERE (\"Id\" = 1)", sql); } [Fact] diff --git a/FreeSql.Tests/Sqlite/SqliteExpression/ConvertTest.cs b/FreeSql.Tests/Sqlite/SqliteExpression/ConvertTest.cs index 8cbee76d..99cff2e0 100644 --- a/FreeSql.Tests/Sqlite/SqliteExpression/ConvertTest.cs +++ b/FreeSql.Tests/Sqlite/SqliteExpression/ConvertTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.SqliteExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -36,7 +36,7 @@ namespace FreeSql.Tests.SqliteExpression { public void ToBoolean() { //var data = new List(); //data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 2) > 0).ToList()); - //SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` + //SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` //FROM `tb_topic` a //WHERE ((a.`Clicks` not in ('0','false'))) } diff --git a/FreeSql.Tests/Sqlite/SqliteExpression/DateTimeTest.cs b/FreeSql.Tests/Sqlite/SqliteExpression/DateTimeTest.cs index edb1b7fc..55329fd6 100644 --- a/FreeSql.Tests/Sqlite/SqliteExpression/DateTimeTest.cs +++ b/FreeSql.Tests/Sqlite/SqliteExpression/DateTimeTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.SqliteExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -39,7 +39,7 @@ namespace FreeSql.Tests.SqliteExpression { public void Now() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.Now.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(now(), '%Y-%m-%d') as datetime)) } @@ -47,7 +47,7 @@ namespace FreeSql.Tests.SqliteExpression { public void UtcNow() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.UtcNow.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(utc_timestamp(), '%Y-%m-%d') as datetime)) } @@ -55,7 +55,7 @@ namespace FreeSql.Tests.SqliteExpression { public void MinValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.MinValue.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(cast('0001/1/1 0:00:00' as datetime), '%Y-%m-%d') as datetime)) } @@ -63,7 +63,7 @@ namespace FreeSql.Tests.SqliteExpression { public void MaxValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.Date == DateTime.MaxValue.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(cast('9999/12/31 23:59:59' as datetime), '%Y-%m-%d') as datetime)) } @@ -73,29 +73,29 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.Date == DateTime.Now.Date).ToList()); data.Add(select.Where(a => a.Type.Time.Date > DateTime.Now.Date).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Date > DateTime.Now.Date).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(now(), '%Y-%m-%d') as datetime)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (cast(date_format(a__Type.`Time`, '%Y-%m-%d') as datetime) > cast(date_format(now(), '%Y-%m-%d') as datetime)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (cast(date_format(a__Type__Parent.`Time2`, '%Y-%m-%d') as datetime) > cast(date_format(now(), '%Y-%m-%d') as datetime)); data.Add(select.Where(a => DateTime.Now.Subtract(a.CreateTime.Date).TotalSeconds > 0).ToList()); data.Add(select.Where(a => DateTime.Now.Subtract(a.Type.Time.Date).TotalSeconds > 0).ToList()); data.Add(select.Where(a => DateTime.Now.Subtract(a.Type.Parent.Time2.Date).TotalSeconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((timestampdiff(microsecond, cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((timestampdiff(microsecond, cast(date_format(a__Type.`Time`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((timestampdiff(microsecond, cast(date_format(a__Type__Parent.`Time2`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0) } @@ -105,15 +105,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.TimeOfDay == DateTime.Now.TimeOfDay).ToList()); data.Add(select.Where(a => a.Type.Time.TimeOfDay > DateTime.Now.TimeOfDay).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.TimeOfDay > DateTime.Now.TimeOfDay).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((timestampdiff(microsecond, date_format(a__Type.`Time`, '1970-1-1 %H:%i:%s.%f'), a__Type.`Time`) + 62135596800000000) > (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((timestampdiff(microsecond, date_format(a__Type__Parent.`Time2`, '1970-1-1 %H:%i:%s.%f'), a__Type__Parent.`Time2`) + 62135596800000000) > (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)) } @@ -123,15 +123,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); data.Add(select.Where(a => a.Type.Time.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((dayofweek(a.`CreateTime`) - 1) > (dayofweek(now()) - 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((dayofweek(a__Type.`Time`) - 1) > (dayofweek(now()) - 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((dayofweek(a__Type__Parent.`Time2`) - 1) > (dayofweek(now()) - 1)) } @@ -141,15 +141,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.Day > DateTime.Now.Day).ToList()); data.Add(select.Where(a => a.Type.Time.Day > DateTime.Now.Day).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Day > DateTime.Now.Day).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (dayofmonth(a.`CreateTime`) > dayofmonth(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (dayofmonth(a__Type.`Time`) > dayofmonth(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (dayofmonth(a__Type__Parent.`Time2`) > dayofmonth(now())) } @@ -159,15 +159,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.DayOfYear > DateTime.Now.DayOfYear).ToList()); data.Add(select.Where(a => a.Type.Time.DayOfYear > DateTime.Now.DayOfYear).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.DayOfYear > DateTime.Now.DayOfYear).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (dayofyear(a.`CreateTime`) > dayofyear(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (dayofyear(a__Type.`Time`) > dayofyear(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (dayofyear(a__Type__Parent.`Time2`) > dayofyear(now())) } @@ -177,15 +177,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.Month > DateTime.Now.Month).ToList()); data.Add(select.Where(a => a.Type.Time.Month > DateTime.Now.Month).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Month > DateTime.Now.Month).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (month(a.`CreateTime`) > month(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (month(a__Type.`Time`) > month(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (month(a__Type__Parent.`Time2`) > month(now())) } @@ -195,15 +195,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.Year > DateTime.Now.Year).ToList()); data.Add(select.Where(a => a.Type.Time.Year > DateTime.Now.Year).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Year > DateTime.Now.Year).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (year(a.`CreateTime`) > year(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (year(a__Type.`Time`) > year(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (year(a__Type__Parent.`Time2`) > year(now())) } @@ -213,15 +213,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.Hour > DateTime.Now.Hour).ToList()); data.Add(select.Where(a => a.Type.Time.Hour > DateTime.Now.Hour).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Hour > DateTime.Now.Hour).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (hour(a.`CreateTime`) > hour(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (hour(a__Type.`Time`) > hour(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (hour(a__Type__Parent.`Time2`) > hour(now())) } @@ -231,15 +231,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.Minute > DateTime.Now.Minute).ToList()); data.Add(select.Where(a => a.Type.Time.Minute > DateTime.Now.Minute).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Minute > DateTime.Now.Minute).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (minute(a.`CreateTime`) > minute(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (minute(a__Type.`Time`) > minute(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (minute(a__Type__Parent.`Time2`) > minute(now())) } @@ -249,15 +249,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.Second > DateTime.Now.Second).ToList()); data.Add(select.Where(a => a.Type.Time.Second > DateTime.Now.Second).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Second > DateTime.Now.Second).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (second(a.`CreateTime`) > second(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (second(a__Type.`Time`) > second(now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (second(a__Type__Parent.`Time2`) > second(now())) } @@ -267,15 +267,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.Millisecond > DateTime.Now.Millisecond).ToList()); data.Add(select.Where(a => a.Type.Time.Millisecond > DateTime.Now.Millisecond).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Millisecond > DateTime.Now.Millisecond).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (floor(microsecond(a.`CreateTime`) / 1000) > floor(microsecond(now()) / 1000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (floor(microsecond(a__Type.`Time`) / 1000) > floor(microsecond(now()) / 1000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (floor(microsecond(a__Type__Parent.`Time2`) / 1000) > floor(microsecond(now()) / 1000)) } @@ -285,15 +285,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.Ticks > DateTime.Now.Ticks).ToList()); data.Add(select.Where(a => a.Type.Time.Ticks > DateTime.Now.Ticks).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Ticks > DateTime.Now.Ticks).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((timestampdiff(microsecond, '1970-1-1', a.`CreateTime`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((timestampdiff(microsecond, '1970-1-1', a__Type.`Time`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((timestampdiff(microsecond, '1970-1-1', a__Type__Parent.`Time2`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)) } @@ -303,15 +303,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval ((1 * 86400000000)) microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval ((1 * 86400000000)) microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval ((1 * 86400000000)) microsecond) > now()) } @@ -321,15 +321,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.AddDays(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddDays(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddDays(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) day) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) day) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) day) > now()) } @@ -339,15 +339,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.AddHours(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddHours(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddHours(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) hour) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) hour) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) hour) > now()) } @@ -357,15 +357,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.AddMilliseconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddMilliseconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddMilliseconds(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) * 1000 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) * 1000 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) * 1000 microsecond) > now()) } @@ -375,15 +375,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.AddMinutes(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddMinutes(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddMinutes(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) minute) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) minute) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) minute) > now()) } @@ -393,15 +393,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.AddMonths(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddMonths(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddMonths(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) month) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) month) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) month) > now()) } @@ -411,15 +411,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.AddSeconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddSeconds(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddSeconds(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) second) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) second) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) second) > now()) } @@ -429,15 +429,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.AddTicks(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddTicks(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddTicks(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) / 10 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) / 10 microsecond) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) / 10 microsecond) > now()) } @@ -447,15 +447,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.AddYears(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1) > DateTime.Now).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_add(a.`CreateTime`, interval (1) year) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_add(a__Type.`Time`, interval (1) year) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_add(a__Type__Parent.`Time2`, interval (1) year) > now()) } @@ -465,29 +465,29 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); data.Add(select.Where(a => a.Type.Time.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((timestampdiff(microsecond, now(), a.`CreateTime`)) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((timestampdiff(microsecond, now(), a__Type.`Time`)) / 1000000) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((timestampdiff(microsecond, now(), a__Type__Parent.`Time2`)) / 1000000) > 0); data.Add(select.Where(a => a.CreateTime.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); data.Add(select.Where(a => a.Type.Time.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (date_sub(a.`CreateTime`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (date_sub(a__Type.`Time`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (date_sub(a__Type__Parent.`Time2`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`) } @@ -497,15 +497,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.AddYears(1).Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1).Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).Equals(DateTime.Now)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((date_add(a.`CreateTime`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((date_add(a__Type.`Time`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((date_add(a__Type__Parent.`Time2`, interval (1) year) = now())) } @@ -515,15 +515,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.ToString().Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1).ToString().Equals(DateTime.Now)).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).ToString().Equals(DateTime.Now)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((date_format(a.`CreateTime`, '%Y-%m-%d %H:%i:%s.%f') = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((date_format(date_add(a__Type.`Time`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((date_format(date_add(a__Type__Parent.`Time2`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') = now())) } @@ -534,15 +534,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.CreateTime.CompareTo(DateTime.Now) == 0).ToList()); data.Add(select.Where(a => a.Type.Time.AddYears(1).CompareTo(DateTime.Now) == 0).ToList()); data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).CompareTo(DateTime.Now) == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((a.`CreateTime`) - (now())) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((date_add(a__Type.`Time`, interval (1) year)) - (now())) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((date_add(a__Type__Parent.`Time2`, interval (1) year)) - (now())) = 0) } @@ -552,15 +552,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => DateTime.DaysInMonth(a.CreateTime.Year, a.CreateTime.Month) > 30).ToList()); data.Add(select.Where(a => DateTime.DaysInMonth(a.Type.Time.Year, a.Type.Time.Month) > 30).ToList()); data.Add(select.Where(a => DateTime.DaysInMonth(a.Type.Parent.Time2.Year, a.Type.Parent.Time2.Month) > 30).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (dayofmonth(last_day(concat(year(a.`CreateTime`), month(a.`CreateTime`), '-01'))) > 30); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (dayofmonth(last_day(concat(year(a__Type.`Time`), month(a__Type.`Time`), '-01'))) > 30); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (dayofmonth(last_day(concat(year(a__Type__Parent.`Time2`), month(a__Type__Parent.`Time2`), '-01'))) > 30) } @@ -570,15 +570,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => DateTime.Equals(a.CreateTime.AddYears(1), DateTime.Now)).ToList()); data.Add(select.Where(a => DateTime.Equals(a.Type.Time.AddYears(1), DateTime.Now)).ToList()); data.Add(select.Where(a => DateTime.Equals(a.Type.Parent.Time2.AddYears(1), DateTime.Now)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE ((date_add(a.`CreateTime`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE ((date_add(a__Type.`Time`, interval (1) year) = now())); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE ((date_add(a__Type__Parent.`Time2`, interval (1) year) = now())) } @@ -588,15 +588,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => DateTime.IsLeapYear(a.CreateTime.Year)).ToList()); data.Add(select.Where(a => DateTime.IsLeapYear(a.Type.Time.AddYears(1).Year)).ToList()); data.Add(select.Where(a => DateTime.IsLeapYear(a.Type.Parent.Time2.AddYears(1).Year)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (((year(a.`CreateTime`)) % 4 = 0 AND (year(a.`CreateTime`)) % 100 <> 0 OR (year(a.`CreateTime`)) % 400 = 0)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (((year(date_add(a__Type.`Time`, interval (1) year))) % 4 = 0 AND (year(date_add(a__Type.`Time`, interval (1) year))) % 100 <> 0 OR (year(date_add(a__Type.`Time`, interval (1) year))) % 400 = 0)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (((year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 4 = 0 AND (year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 100 <> 0 OR (year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 400 = 0)) } @@ -606,15 +606,15 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => DateTime.Parse(a.CreateTime.ToString()) > DateTime.Now).ToList()); data.Add(select.Where(a => DateTime.Parse(a.Type.Time.AddYears(1).ToString()) > DateTime.Now).ToList()); data.Add(select.Where(a => DateTime.Parse(a.Type.Parent.Time2.AddYears(1).ToString()) > DateTime.Now).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic111333` a //WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type //WHERE (cast(date_format(date_add(a__Type.`Time`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9 //FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent //WHERE (cast(date_format(date_add(a__Type__Parent.`Time2`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()) } diff --git a/FreeSql.Tests/Sqlite/SqliteExpression/MathTest.cs b/FreeSql.Tests/Sqlite/SqliteExpression/MathTest.cs index 77b223c2..0f0bb32a 100644 --- a/FreeSql.Tests/Sqlite/SqliteExpression/MathTest.cs +++ b/FreeSql.Tests/Sqlite/SqliteExpression/MathTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.SqliteExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } diff --git a/FreeSql.Tests/Sqlite/SqliteExpression/StringTest.cs b/FreeSql.Tests/Sqlite/SqliteExpression/StringTest.cs index 8c404784..89618733 100644 --- a/FreeSql.Tests/Sqlite/SqliteExpression/StringTest.cs +++ b/FreeSql.Tests/Sqlite/SqliteExpression/StringTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.SqliteExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -36,7 +36,7 @@ namespace FreeSql.Tests.SqliteExpression { public void Empty() { var data = new List(); data.Add(select.Where(a => (a.Title ?? "") == string.Empty).ToSql()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (ifnull(a.`Title`, '') = '') } @@ -48,38 +48,38 @@ namespace FreeSql.Tests.SqliteExpression { list.Add(select.Where(a => a.Title.StartsWith(a.Title)).ToList()); list.Add(select.Where(a => a.Title.StartsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => a.Title.StartsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE '%aaa') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', a.`Title`)) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', concat(a.`Title`, 1))) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((a.`Title`) LIKE concat('%', a__Type.`Name`)) list.Add(select.Where(a => (a.Title + "aaa").StartsWith("aaa")).ToList()); list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Title)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE '%aaa') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a.`Title`)) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', concat(a.`Title`, 1))) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`)) } @@ -90,38 +90,38 @@ namespace FreeSql.Tests.SqliteExpression { list.Add(select.Where(a => a.Title.EndsWith(a.Title)).ToList()); list.Add(select.Where(a => a.Title.EndsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => a.Title.EndsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE 'aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat(a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat(concat(a.`Title`, 1), '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((a.`Title`) LIKE concat(a__Type.`Name`, '%')) list.Add(select.Where(a => (a.Title + "aaa").EndsWith("aaa")).ToList()); list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Title)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Title + 1)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE 'aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat(a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat(concat(a.`Title`, 1), '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((concat(a.`Title`, 'aaa')) LIKE concat(a__Type.`Name`, '%')) } @@ -132,38 +132,38 @@ namespace FreeSql.Tests.SqliteExpression { list.Add(select.Where(a => a.Title.Contains(a.Title)).ToList()); list.Add(select.Where(a => a.Title.Contains(a.Title + 1)).ToList()); list.Add(select.Where(a => a.Title.Contains(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE '%aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((a.`Title`) LIKE concat('%', a.`Title` +1, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((a.`Title`) LIKE concat('%', a__Type.`Name`, '%')) list.Add(select.Where(a => (a.Title + "aaa").Contains("aaa")).ToList()); list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title + 1)).ToList()); list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Type.Name)).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE '%aaa%') - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a.`Title`, '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', concat(a.`Title`, 1), '%')) - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`, '%')) } @@ -174,38 +174,38 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.Title.ToLower() == a.Title).ToList()); data.Add(select.Where(a => a.Title.ToLower() == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.ToLower() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(a.`Title`) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE(lower(a.`Title`) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == a.Title).ToList()); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE(lower(concat(lower(a.`Title`), 'aaa')) = a__Type.`Name`) } @@ -216,38 +216,38 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.Title.ToUpper() == a.Title).ToList()); data.Add(select.Where(a => a.Title.ToUpper() == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.ToUpper() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(a.`Title`) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (upper(a.`Title`) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == a.Title).ToList()); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (upper(concat(upper(a.`Title`), 'aaa')) = a__Type.`Name`) } @@ -258,38 +258,38 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.Title.Substring(0) == a.Title).ToList()); data.Add(select.Where(a => a.Title.Substring(0) == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.Substring(0) == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(a.`Title`, 1) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(a.`Title`, 1) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(a.`Title`, 1) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (substr(a.`Title`, 1) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(a.Title.Length) == "aaa").ToList()); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(0, a.Title.Length) == a.Title).ToList()); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(0, 3) == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(1, 2) == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), char_length(a.`Title`) + 1) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 1, char_length(a.`Title`)) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 1, 3) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 2, 2) = a__Type.`Name`) } @@ -300,38 +300,38 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.Title.Length == 1).ToList()); data.Add(select.Where(a => a.Title.Length == a.Title.Length + 1).ToList()); data.Add(select.Where(a => a.Title.Length == a.Type.Name.Length).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(a.`Title`) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(a.`Title`) = 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(a.`Title`) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (char_length(a.`Title`) = char_length(a__Type.`Name`)); data.Add(select.Where(a => (a.Title + "aaa").Length == 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").Length == 1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").Length == a.Title.Length + 1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").Length == a.Type.Name.Length).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(concat(a.`Title`, 'aaa')) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(concat(a.`Title`, 'aaa')) = 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (char_length(concat(a.`Title`, 'aaa')) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (char_length(concat(a.`Title`, 'aaa')) = char_length(a__Type.`Name`)) } @@ -342,38 +342,38 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == -1).ToList()); data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == (a.Title.Length + 1)).ToList()); data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == a.Type.Name.Length + 1).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(a.`Title`, 'aaa') - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = char_length(a__Type.`Name`) + 1); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa") == -1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == -1).ToList()); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == (a.Title.Length + 1)).ToList()); data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == a.Type.Name.Length + 1).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa') - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = -1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = char_length(a.`Title`) + 1); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = char_length(a__Type.`Name`) + 1) } @@ -384,38 +384,38 @@ namespace FreeSql.Tests.SqliteExpression { //data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == a.Title).ToList()); //data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == (a.Title + 1)).ToList()); //data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == a.Type.Name).ToList()); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 ////FROM `tb_topic` a ////WHERE (lpad(a.`Title`, 10, 'a') = 'aaa'); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 ////FROM `tb_topic` a ////WHERE (lpad(a.`Title`, 10, 'a') = a.`Title`); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 ////FROM `tb_topic` a ////WHERE (lpad(a.`Title`, 10, 'a') = concat(a.`Title`, 1)); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 ////FROM `tb_topic` a, `TestTypeInfo` a__Type ////WHERE (lpad(a.`Title`, 10, 'a') = a__Type.`Name`); //data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == "aaa").ToList()); //data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == a.Title).ToList()); //data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == (a.Title + 1)).ToList()); //data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == a.Type.Name).ToList()); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 ////FROM `tb_topic` a ////WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = 'aaa'); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 ////FROM `tb_topic` a ////WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a.`Title`); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 ////FROM `tb_topic` a ////WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = concat(a.`Title`, 1)); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 ////FROM `tb_topic` a, `TestTypeInfo` a__Type ////WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a__Type.`Name`) } @@ -426,38 +426,38 @@ namespace FreeSql.Tests.SqliteExpression { //data.Add(select.Where(a => a.Title.PadRight(10, 'a') == a.Title).ToList()); //data.Add(select.Where(a => a.Title.PadRight(10, 'a') == (a.Title + 1)).ToList()); //data.Add(select.Where(a => a.Title.PadRight(10, 'a') == a.Type.Name).ToList()); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 ////FROM `tb_topic` a ////WHERE (rpad(a.`Title`, 10, 'a') = 'aaa'); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 ////FROM `tb_topic` a ////WHERE (rpad(a.`Title`, 10, 'a') = a.`Title`); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 ////FROM `tb_topic` a ////WHERE (rpad(a.`Title`, 10, 'a') = concat(a.`Title`, 1)); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 ////FROM `tb_topic` a, `TestTypeInfo` a__Type ////WHERE (rpad(a.`Title`, 10, 'a') = a__Type.`Name`); //data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == "aaa").ToList()); //data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == a.Title).ToList()); //data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == (a.Title + 1)).ToList()); //data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == a.Type.Name).ToList()); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 ////FROM `tb_topic` a ////WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = 'aaa'); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 ////FROM `tb_topic` a ////WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a.`Title`); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 ////FROM `tb_topic` a ////WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = concat(a.`Title`, 1)); - ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + ////SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 ////FROM `tb_topic` a, `TestTypeInfo` a__Type ////WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a__Type.`Name`) } @@ -468,38 +468,38 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.Title.Trim('a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.Trim('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.Trim('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('a' from a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('b' from trim('a' from a.`Title`)) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim('c' from trim('b' from trim('a' from a.`Title`))) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.Trim() + "aaa").Trim() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.Trim('a') + "aaa").Trim('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.Trim('a', 'b') + "aaa").Trim('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.Trim('a', 'b', 'c') + "aaa").Trim('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(concat(trim(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('a' from concat(trim('a' from a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim('b' from trim('a' from concat(trim('b' from trim('a' from a.`Title`)), 'aaa'))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim('c' from trim('b' from trim('a' from concat(trim('c' from trim('b' from trim('a' from a.`Title`))), 'aaa')))) = a__Type.`Name`) } @@ -510,38 +510,38 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.Title.TrimStart('a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.TrimStart('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.TrimStart('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (ltrim(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from trim(leading 'a' from a.`Title`)) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))))) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.TrimStart() + "aaa").TrimStart() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.TrimStart('a') + "aaa").TrimStart('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.TrimStart('a', 'b') + "aaa").TrimStart('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.TrimStart('a', 'b', 'c') + "aaa").TrimStart('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (ltrim(concat(ltrim(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'a' from trim(leading 'a' from a.`Title`)), 'aaa'))) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))), 'aaa'))))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))))), 'aaa'))))))) = a__Type.`Name`) } @@ -552,38 +552,38 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.Title.TrimEnd('a') == a.Title).ToList()); data.Add(select.Where(a => a.Title.TrimEnd('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rtrim(a.`Title`) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from a.`Title`) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(trailing 'a' from a.`Title`)) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from a.`Title`))) = a__Type.`Name`); data.Add(select.Where(a => (a.Title.TrimEnd() + "aaa").TrimEnd() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.TrimEnd('a') + "aaa").TrimEnd('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.TrimEnd('a', 'b') + "aaa").TrimEnd('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.TrimEnd('a', 'b', 'c') + "aaa").TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (rtrim(concat(rtrim(a.`Title`), 'aaa')) = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'a' from concat(trim(trailing 'a' from a.`Title`), 'aaa')) = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (trim(trailing 'b' from trim(trailing 'a' from concat(trim(trailing 'b' from trim(trailing 'a' from a.`Title`)), 'aaa'))) = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from concat(trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from a.`Title`))), 'aaa')))) = a__Type.`Name`) } @@ -594,38 +594,38 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c") == a.Title).ToList()); data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c").Replace("c", "a") == (a.Title + 1)).ToList()); data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c").Replace(a.Type.Name, "a") == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (replace(a.`Title`, 'a', 'b') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (replace(replace(a.`Title`, 'a', 'b'), 'b', 'c') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'c', 'a') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), a__Type.`Name`, 'a') = a__Type.`Name`); data.Add(select.Where(a => (a.Title.Replace("a", "b") + "aaa").TrimEnd() == "aaa").ToList()); data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c") + "aaa").TrimEnd('a') == a.Title).ToList()); data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c").Replace("c", "a") + "aaa").TrimEnd('a', 'b') == (a.Title + 1)).ToList()); data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c").Replace(a.Type.Name, "a") + "aaa").TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (concat(replace(a.`Title`, 'a', 'b'), 'aaa') = 'aaa'); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (concat(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'aaa') = a.`Title`); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (concat(replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'c', 'a'), 'aaa') = concat(a.`Title`, 1)); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (concat(replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), a__Type.`Name`, 'a'), 'aaa') = a__Type.`Name`) } @@ -636,38 +636,38 @@ namespace FreeSql.Tests.SqliteExpression { data.Add(select.Where(a => a.Title.CompareTo(a.Title) > 0).ToList()); data.Add(select.Where(a => a.Title.CompareTo(a.Title + 1) == 0).ToList()); data.Add(select.Where(a => a.Title.CompareTo(a.Title + a.Type.Name) == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(a.`Title`, a.`Title`) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(a.`Title`, a.`Title`) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(a.`Title`, concat(a.`Title`, 1)) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (strcmp(a.`Title`, concat(a.`Title`, a__Type.`Name`)) = 0); data.Add(select.Where(a => (a.Title + "aaa").CompareTo("aaa") == 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Title) > 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Title + 1) == 0).ToList()); data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Type.Name) == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(concat(a.`Title`, 'aaa'), 'aaa') = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(concat(a.`Title`, 'aaa'), a.`Title`) > 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (strcmp(concat(a.`Title`, 'aaa'), concat(a.`Title`, 1)) = 0); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 //FROM `tb_topic` a, `TestTypeInfo` a__Type //WHERE (strcmp(concat(a.`Title`, 'aaa'), a__Type.`Name`) = 0) } diff --git a/FreeSql.Tests/Sqlite/SqliteExpression/TimeSpanTest.cs b/FreeSql.Tests/Sqlite/SqliteExpression/TimeSpanTest.cs index 8f3a763c..74b1fe35 100644 --- a/FreeSql.Tests/Sqlite/SqliteExpression/TimeSpanTest.cs +++ b/FreeSql.Tests/Sqlite/SqliteExpression/TimeSpanTest.cs @@ -14,7 +14,7 @@ namespace FreeSql.Tests.SqliteExpression { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } - public int TestTypeInfoGuid { get; set; } + public int TypeGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } @@ -35,7 +35,7 @@ namespace FreeSql.Tests.SqliteExpression { public void Zero() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) > 0) } @@ -43,7 +43,7 @@ namespace FreeSql.Tests.SqliteExpression { public void MinValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay > TimeSpan.MinValue).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) > -922337203685477580) } @@ -51,7 +51,7 @@ namespace FreeSql.Tests.SqliteExpression { public void MaxValue() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay < TimeSpan.MaxValue).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) < 922337203685477580) } @@ -59,7 +59,7 @@ namespace FreeSql.Tests.SqliteExpression { public void Days() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Days == 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 86400000000) = 0) } @@ -67,7 +67,7 @@ namespace FreeSql.Tests.SqliteExpression { public void Hours() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Hours > 0).ToSql()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 3600000000) mod 24 > 0) } @@ -75,7 +75,7 @@ namespace FreeSql.Tests.SqliteExpression { public void Milliseconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Milliseconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 1000 mod 1000) > 0) } @@ -83,7 +83,7 @@ namespace FreeSql.Tests.SqliteExpression { public void Minutes() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Minutes > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 60000000 mod 60) > 0) } @@ -91,7 +91,7 @@ namespace FreeSql.Tests.SqliteExpression { public void Seconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Seconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 1000000 mod 60) > 0) } @@ -99,7 +99,7 @@ namespace FreeSql.Tests.SqliteExpression { public void Ticks() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Ticks > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) * 10) > 0) } @@ -107,7 +107,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TotalDays() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalDays > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 86400000000) > 0) } @@ -115,7 +115,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TotalHours() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalHours > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 3600000000) > 0) } @@ -123,7 +123,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TotalMilliseconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalMilliseconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 1000) > 0) } @@ -131,7 +131,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TotalMinutes() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalMinutes > 0).ToSql()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 60000000) > 0) } @@ -139,7 +139,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TotalSeconds() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalSeconds > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 1000000) > 0) } @@ -147,7 +147,7 @@ namespace FreeSql.Tests.SqliteExpression { public void Add() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Add(TimeSpan.FromDays(1)) > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) + (1 * 86400000000)) > 0) } @@ -155,7 +155,7 @@ namespace FreeSql.Tests.SqliteExpression { public void Subtract() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Subtract(TimeSpan.FromDays(1)) > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) - (1 * 86400000000)) > 0) } @@ -163,7 +163,7 @@ namespace FreeSql.Tests.SqliteExpression { public void CompareTo() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.CompareTo(TimeSpan.FromDays(1)) > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) - ((1 * 86400000000))) > 0) } @@ -171,7 +171,7 @@ namespace FreeSql.Tests.SqliteExpression { public void this_Equals() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.Equals(TimeSpan.FromDays(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) } @@ -179,7 +179,7 @@ namespace FreeSql.Tests.SqliteExpression { public void this_ToString() { var data = new List(); data.Add(select.Where(a => a.CreateTime.TimeOfDay.ToString() == "ssss").ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (date_format(date_add(cast('0001/1/1 0:00:00' as datetime), interval (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) microsecond), '%Y-%m-%d %H:%i:%s.%f') = 'ssss') } @@ -188,7 +188,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TimeSpan_Compare() { var data = new List(); data.Add(select.Where(a => TimeSpan.Compare(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1)) > 0).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) - ((1 * 86400000000))) > 0) } @@ -196,7 +196,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TimeSpan_Equals() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) } @@ -204,7 +204,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TimeSpan_FromDays() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) } @@ -212,7 +212,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TimeSpan_FromHours() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromHours(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 3600000000))) } @@ -220,7 +220,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TimeSpan_FromMilliseconds() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromMilliseconds(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 1000))) } @@ -228,7 +228,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TimeSpan_FromMinutes() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromMinutes(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 60000000))) } @@ -236,7 +236,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TimeSpan_FromSeconds() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromSeconds(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 1000000))) } @@ -244,7 +244,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TimeSpan_FromTicks() { var data = new List(); data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromTicks(1))).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 / 10))) } @@ -252,7 +252,7 @@ namespace FreeSql.Tests.SqliteExpression { public void TimeSpan_Parse() { var data = new List(); data.Add(select.Where(a => TimeSpan.Parse(a.CreateTime.TimeOfDay.ToString()) > TimeSpan.Zero).ToList()); - //SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 + //SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 //FROM `tb_topic` a //WHERE (cast(date_format(date_add(cast('0001/1/1 0:00:00' as datetime), interval (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) microsecond), '%Y-%m-%d %H:%i:%s.%f') as signed) > 0) } diff --git a/FreeSql.Tests/UnitTest1.cs b/FreeSql.Tests/UnitTest1.cs index da448bbb..87688a00 100644 --- a/FreeSql.Tests/UnitTest1.cs +++ b/FreeSql.Tests/UnitTest1.cs @@ -13,7 +13,7 @@ namespace FreeSql.Tests { public class Order { [Column(IsPrimary = true)] - public int OrderID { get; set; } + public int Id { get; set; } public string OrderTitle { get; set; } public string CustomerName { get; set; } public DateTime TransactionDate { get; set; } @@ -21,7 +21,7 @@ namespace FreeSql.Tests { } public class OrderDetail { [Column(IsPrimary = true)] - public int DetailId { get; set; } + public int Id { get; set; } public int OrderId { get; set; } public virtual Order Order { get; set; } @@ -31,19 +31,44 @@ namespace FreeSql.Tests { [Fact] public void Test1() { + var parentSelect1 = select.Where(a => a.Type.Parent.Parent.Parent.Parent.Name == "").Where(b => b.Type.Name == "").ToSql(); + + var collSelect1 = g.mysql.Select().Where(a => - a.OrderDetails.AsSelect().Where(b => b.OrderId == a.OrderID).Any() + a.OrderDetails.AsSelect().Any(b => b.Id > 100) ); var collectionSelect = select.Where(a => - a.Type.Guid == a.TypeGuid && - a.Type.Parent.Id == a.Type.ParentId && - a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any(b => b.ParentId == a.Type.Parent.Id) + //a.Type.Guid == a.TypeGuid && + //a.Type.Parent.Id == a.Type.ParentId && + a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any( + //b => b.ParentId == a.Type.Parent.Id + ) + ); + + var collectionSelect2 = select.Where(a => + a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any( + b => b.Parent.Name == "xxx" && b.Parent.Parent.Name == "ccc" + && b.Parent.Parent.Parent.Types.AsSelect().Any(cb => cb.Name == "yyy") + ) + ); + + var collectionSelect3 = select.Where(a => + a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any( + bbb => bbb.Parent.Types.AsSelect().Where(lv2 => lv2.Name == bbb.Name + "111").Any( + ) + ) ); - var order = g.mysql.Select().Where(a => a.OrderID == 1).ToOne(); //ѯ + var order = g.mysql.Select().Where(a => a.Id == 1).ToOne(); //ѯ + if (order == null) { + var orderId = g.mysql.Insert(new Order { }).ExecuteIdentity(); + order = g.mysql.Select(orderId).ToOne(); + } + + var orderDetail1 = order.OrderDetails; //һηʣѯݿ var orderDetail2 = order.OrderDetails; //ڶηʣ var order1 = orderDetail1.FirstOrDefault(); //ʵԣʱݿ⣬Ϊ OrderDetails ѯʱ˸ @@ -206,6 +231,7 @@ namespace FreeSql.Tests { } class TestTypeInfo { + [Column(IsIdentity = true)] public int Guid { get; set; } public int ParentId { get; set; } public TestTypeParentInfo Parent { get; set; } @@ -216,6 +242,9 @@ namespace FreeSql.Tests { public int Id { get; set; } public string Name { get; set; } + public int ParentId { get; set; } + public TestTypeParentInfo Parent { get; set; } + public List Types { get; set; } } } diff --git a/FreeSql/Internal/CommonExpression.cs b/FreeSql/Internal/CommonExpression.cs index dc544a73..a52e32d9 100644 --- a/FreeSql/Internal/CommonExpression.cs +++ b/FreeSql/Internal/CommonExpression.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Collections.Concurrent; using System.Data.Common; using System.Linq; using System.Linq.Expressions; @@ -202,7 +203,9 @@ namespace FreeSql.Internal { } } } - + static ConcurrentDictionary _dicExpressionLambdaToSqlAsSelectMethodInfo = new ConcurrentDictionary(); + static ConcurrentDictionary _dicExpressionLambdaToSqlAsSelectWhereMethodInfo = new ConcurrentDictionary(); + static ConcurrentDictionary _dicNullableValueProperty = new ConcurrentDictionary(); internal string ExpressionLambdaToSql(Expression exp, List _tables, List _selectColumnMap, Func getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) { if (exp == null) return ""; switch (exp.NodeType) { @@ -257,6 +260,11 @@ namespace FreeSql.Internal { List fsqltables = null; var fsqltable1SetAlias = false; Type fsqlType = null; + Stack asSelectBefores = new Stack(); + var asSelectSql = ""; + Type asSelectEntityType = null; + MemberExpression asSelectParentExp1 = null; + Expression asSelectParentExp = null; while (exp3Stack.Any()) { exp3tmp = exp3Stack.Pop(); if (exp3tmp.Type.FullName.StartsWith("FreeSql.ISelect`") && fsql == null) { @@ -265,9 +273,22 @@ namespace FreeSql.Internal { if (exp3tmpCall.Method.Name == "AsSelect" && exp3tmpCall.Object == null) { var exp3tmpArg1Type = exp3tmpCall.Arguments.FirstOrDefault()?.Type; if (exp3tmpArg1Type != null) { - var exp3tmpEleType = exp3tmpArg1Type.GetElementType() ?? exp3tmpArg1Type.GenericTypeArguments.FirstOrDefault(); - if (exp3tmpEleType != null) { - fsql = typeof(IFreeSql).GetMethod("Select", new Type[0]).MakeGenericMethod(exp3tmpEleType).Invoke(_common._orm, null); + asSelectEntityType = exp3tmpArg1Type.GetElementType() ?? exp3tmpArg1Type.GenericTypeArguments.FirstOrDefault(); + if (asSelectEntityType != null) { + fsql = _dicExpressionLambdaToSqlAsSelectMethodInfo.GetOrAdd(asSelectEntityType, asSelectEntityType2 => typeof(IFreeSql).GetMethod("Select", new Type[0]).MakeGenericMethod(asSelectEntityType2)) + .Invoke(_common._orm, null); + + if (asSelectBefores.Any()) { + asSelectParentExp1 = asSelectBefores.Pop() as MemberExpression; + asSelectParentExp = asSelectBefores.Pop(); + if (asSelectParentExp != null) { + var testExecuteExp = asSelectParentExp; + if (asSelectParentExp.NodeType == ExpressionType.Parameter) //执行leftjoin关联 + testExecuteExp = Expression.Property(testExecuteExp, _common.GetTableByEntity(asSelectParentExp.Type).Properties.First().Value); + asSelectSql = ExpressionLambdaToSql(testExecuteExp, _tables, new List(), getSelectGroupingMapString, SelectTableInfoType.LeftJoin, isQuoteName); + + } + } } } } @@ -279,10 +300,11 @@ namespace FreeSql.Internal { fsqltables = fsqlType.GetField("_tables", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(fsql) as List; //fsqltables[0].Alias = $"{_tables[0].Alias}_{fsqltables[0].Alias}"; fsqltables.AddRange(_tables.Select(a => new SelectTableInfo { - Alias = a.Type == SelectTableInfoType.Parent ? a.Alias : $"__parent_{a.Alias}_parent__", + Alias = a.Alias, On = "1=1", Table = a.Table, - Type = SelectTableInfoType.Parent + Type = SelectTableInfoType.Parent, + Parameter = a.Parameter })); } else if (fsqlType != null) { var call3Exp = exp3tmp as MethodCallExpression; @@ -303,23 +325,48 @@ namespace FreeSql.Internal { } method.Invoke(fsql, args); } + if (fsql == null) asSelectBefores.Push(exp3tmp); } if (fsql != null) { + if (asSelectEntityType != null) { //执行 asSelect() 的关联 + var fsqlWhere = _dicExpressionLambdaToSqlAsSelectWhereMethodInfo.GetOrAdd(asSelectEntityType, asSelectEntityType3 => + typeof(ISelect<>).MakeGenericType(asSelectEntityType3).GetMethod("Where", new[] { + typeof(Expression<>).MakeGenericType(typeof(Func<,>).MakeGenericType(asSelectEntityType3, typeof(bool))) + })); + var parm123Tb = _common.GetTableByEntity(asSelectParentExp.Type); + var parm123Ref = parm123Tb.GetTableRef(asSelectParentExp1.Member.Name); + var fsqlWhereParam = fsqltables.First().Parameter; //Expression.Parameter(asSelectEntityType); + Expression fsqlWhereExp = null; + for (var mn = 0; mn < parm123Ref.Columns.Count; mn++) { + var col1 = parm123Ref.RefColumns[mn]; + var col2 = parm123Ref.Columns[mn]; + var pexp1 = Expression.Property(fsqlWhereParam, col1.CsName); + var pexp2 = Expression.Property(asSelectParentExp, col2.CsName); + if (col1.CsType != col2.CsType) { + if (col1.CsType.IsNullableType()) pexp1 = Expression.Property(pexp1, _dicNullableValueProperty.GetOrAdd(col1.CsType, ct1 => ct1.GetProperty("Value"))); + if (col2.CsType.IsNullableType()) pexp2 = Expression.Property(pexp2, _dicNullableValueProperty.GetOrAdd(col2.CsType, ct2 => ct2.GetProperty("Value"))); + } + var tmpExp = Expression.Equal(pexp1, pexp2); + if (mn == 0) fsqlWhereExp = tmpExp; + else fsqlWhereExp = Expression.And(fsqlWhereExp, tmpExp); + } + fsqlWhere.Invoke(fsql, new object[] { Expression.Lambda(fsqlWhereExp, fsqlWhereParam) }); + } + asSelectBefores.Clear(); var sql = fsqlType.GetMethod("ToSql", new Type[] { typeof(string) })?.Invoke(fsql, new object[] { "1" })?.ToString(); if (string.IsNullOrEmpty(sql) == false) { - foreach (var tb in _tables) - sql = sql.Replace($"__parent_{tb.Alias}_parent__", tb.Alias); - return $"exists({sql})"; + return $"exists({sql.Replace("\r\n", "\r\n\t")})"; } } + asSelectBefores.Clear(); } } - var eleType = callType.GetElementType() ?? callType.GenericTypeArguments.FirstOrDefault(); - if (eleType != null && typeof(IEnumerable<>).MakeGenericType(eleType).IsAssignableFrom(callType)) { //集合导航属性子查询 - if (exp3.Method.Name == "Any") { //exists + //var eleType = callType.GetElementType() ?? callType.GenericTypeArguments.FirstOrDefault(); + //if (eleType != null && typeof(IEnumerable<>).MakeGenericType(eleType).IsAssignableFrom(callType)) { //集合导航属性子查询 + // if (exp3.Method.Name == "Any") { //exists - } - } + // } + //} var other3Exp = ExpressionLambdaToSqlOther(exp3, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName); if (string.IsNullOrEmpty(other3Exp) == false) return other3Exp; throw new Exception($"未实现函数表达式 {exp3} 解析"); @@ -384,21 +431,77 @@ namespace FreeSql.Internal { if (isQuoteName) name = _common.QuoteSqlName(name); return name; } - Func getOrAddTable = (tbtmp, alias, isa) => { - var finds = _tables.Where((a2, c2) => (isa || c2 > 0) && a2.Table.CsName == tbtmp.CsName).ToArray(); //外部表,内部表一起查 - if (finds.Length > 1) { - finds = _tables.Where((a2, c2) => a2.Table.CsName == tbtmp.CsName && a2.Type == SelectTableInfoType.Parent && a2.Alias == $"__parent_{alias}_parent__").ToArray(); //查询外部表 - if (finds.Any() == false) { - finds = _tables.Where((a2, c2) => (isa || c2 > 0) && a2.Table.CsName == tbtmp.CsName && a2.Type != SelectTableInfoType.Parent).ToArray(); //查询内部表 - if (finds.Length > 1) finds = _tables.Where((a2, c2) => (isa || c2 > 0) && a2.Table.CsName == tbtmp.CsName && a2.Type != SelectTableInfoType.Parent && a2.Alias == alias).ToArray(); + Func getOrAddTable = (tbtmp, alias, isa, parmExp, mp) => { + var finds = new SelectTableInfo[0]; + if (isa && parmExp != null) + finds = _tables.Where(a => a.Parameter == parmExp).ToArray(); + if (finds.Length != 1) { + var navdot = string.IsNullOrEmpty(alias) ? new SelectTableInfo[0] : _tables.Where(a2 => a2.Parameter != null && alias.StartsWith($"{a2.Alias}__")).ToArray(); + if (navdot.Length > 0) { + var isthis = navdot[0] == _tables[0]; + finds = _tables.Where(a2 => (isa && a2.Parameter != null || !isa && a2.Parameter == null) && + a2.Table.Type == tbtmp.Type && a2.Alias == alias && a2.Alias.StartsWith($"{navdot[0].Alias}__") && + (isthis && a2.Type != SelectTableInfoType.Parent || !isthis && a2.Type == SelectTableInfoType.Parent)).ToArray(); + } else { + finds = _tables.Where(a2 => (isa && a2.Parameter != null || isa && a2.Parameter == null) && + a2.Table.Type == tbtmp.Type && a2.Alias == alias).ToArray(); + if (finds.Length != 1) { + finds = _tables.Where(a2 => (isa && a2.Parameter != null || isa && a2.Parameter == null) && + a2.Table.Type == tbtmp.Type).ToArray(); + if (finds.Length != 1) { + finds = _tables.Where(a2 => (isa && a2.Parameter != null || isa && a2.Parameter == null) && + a2.Table.Type == tbtmp.Type).ToArray(); + if (finds.Length != 1) + finds = _tables.Where(a2 => a2.Table.Type == tbtmp.Type).ToArray(); + } + } + } + //finds = _tables.Where((a2, c2) => (isa || a2.Parameter == null) && a2.Table.CsName == tbtmp.CsName && (isthis && a2.Type != SelectTableInfoType.Parent || !isthis)).ToArray(); //外部表,内部表一起查 + //if (finds.Length > 1) { + // finds = _tables.Where((a2, c2) => (isa || a2.Parameter == null) && a2.Table.CsName == tbtmp.CsName && a2.Type == SelectTableInfoType.Parent && a2.Alias == alias).ToArray(); //查询外部表 + // if (finds.Any() == false) { + // finds = _tables.Where((a2, c2) => (isa || a2.Parameter == null) && a2.Table.CsName == tbtmp.CsName && a2.Type != SelectTableInfoType.Parent).ToArray(); //查询内部表 + // if (finds.Length > 1) + // finds = _tables.Where((a2, c2) => (isa || a2.Parameter == null) && a2.Table.CsName == tbtmp.CsName && a2.Type != SelectTableInfoType.Parent && a2.Alias == alias).ToArray(); + // } + //} + } + var find = finds.Length == 1 ? finds.First() : null; + if (find != null && isa && parmExp != null && find.Parameter != parmExp) + find.Parameter = parmExp; + if (find == null) { + _tables.Add(find = new SelectTableInfo { Table = tbtmp, Alias = alias, On = null, Type = mp == null ? tbtype : SelectTableInfoType.LeftJoin, Parameter = isa ? parmExp : null }); + if (mp?.Expression != null) { //导航条件 + var firstTb = _tables.First().Table; + var parentTb = _common.GetTableByEntity(mp.Expression.Type); + var parentTbRef = parentTb.GetTableRef(mp.Member.Name); + Expression navCondExp = null; + for (var mn = 0; mn < parentTbRef.Columns.Count; mn++) { + var col1 = parentTbRef.RefColumns[mn]; + var col2 = parentTbRef.Columns[mn]; + var pexp1 = Expression.Property(mp, col1.CsName); + var pexp2 = Expression.Property(mp.Expression, col2.CsName); + if (col1.CsType != col2.CsType) { + if (col1.CsType.IsNullableType()) pexp1 = Expression.Property(pexp1, _dicNullableValueProperty.GetOrAdd(col1.CsType, ct1 => ct1.GetProperty("Value"))); + if (col2.CsType.IsNullableType()) pexp2 = Expression.Property(pexp2, _dicNullableValueProperty.GetOrAdd(col2.CsType, ct2 => ct2.GetProperty("Value"))); + } + var tmpExp = Expression.Equal(pexp1, pexp2); + if (mn == 0) navCondExp = tmpExp; + else navCondExp = Expression.And(navCondExp, tmpExp); + } + if (find.Type == SelectTableInfoType.InnerJoin || + find.Type == SelectTableInfoType.LeftJoin || + find.Type == SelectTableInfoType.RightJoin) + find.On = ExpressionLambdaToSql(navCondExp, _tables, null, null, find.Type, isQuoteName); + else + find.NavigateCondition = ExpressionLambdaToSql(navCondExp, _tables, null, null, find.Type, isQuoteName); } } - var find = finds.FirstOrDefault(); - if (find == null) _tables.Add(find = new SelectTableInfo { Table = tbtmp, Alias = alias, On = null, Type = tbtype }); return find; }; TableInfo tb2 = null; + ParameterExpression parmExp2 = null; string alias2 = "", name2 = ""; SelectTableInfo find2 = null; while (expStack.Count > 0) { @@ -415,9 +518,11 @@ namespace FreeSql.Internal { var mp2 = exp2 as MemberExpression; if (mp2?.Member.Name == "Key" && mp2.Expression.Type.FullName.StartsWith("FreeSql.ISelectGroupingAggregate`")) continue; if (tb2tmp != null) { - if (exp2.NodeType == ExpressionType.Parameter) alias2 = (exp2 as ParameterExpression).Name; - else alias2 = $"{alias2}__{mp2.Member.Name}"; - find2 = getOrAddTable(tb2tmp, alias2, exp2.NodeType == ExpressionType.Parameter); + if (exp2.NodeType == ExpressionType.Parameter) { + parmExp2 = (exp2 as ParameterExpression); + alias2 = parmExp2.Name; + } else alias2 = $"{alias2}__{mp2.Member.Name}"; + find2 = getOrAddTable(tb2tmp, alias2, exp2.NodeType == ExpressionType.Parameter, parmExp2, mp2); alias2 = find2.Alias; tb2 = tb2tmp; } @@ -426,7 +531,7 @@ namespace FreeSql.Internal { if (_selectColumnMap != null) { var tb3 = _common.GetTableByEntity(mp2.Type); if (tb3 != null) { - var find3 = getOrAddTable(tb2tmp, $"{alias2}__{mp2.Member.Name}", exp2.NodeType == ExpressionType.Parameter); + var find3 = getOrAddTable(tb2tmp, alias2 /*$"{alias2}__{mp2.Member.Name}"*/, exp2.NodeType == ExpressionType.Parameter, parmExp2, mp2); foreach (var tb3c in tb3.Columns.Values) _selectColumnMap.Add(new SelectColumnInfo { Table = find3, Column = tb3c }); diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select0Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select0Provider.cs index bec20864..2a36ad31 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select0Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select0Provider.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Data; using System.Data.Common; using System.Linq; @@ -27,7 +28,7 @@ namespace FreeSql.Internal.CommonProvider { protected CommonExpression _commonExpression; protected DbTransaction _transaction; - internal static void CopyData(Select0Provider from, object to) { + internal static void CopyData(Select0Provider from, object to, ReadOnlyCollection lambParms) { var toType = to?.GetType(); if (toType == null) return; toType.GetField("_limit", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._limit); @@ -38,7 +39,19 @@ namespace FreeSql.Internal.CommonProvider { toType.GetField("_having", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._having); toType.GetField("_where", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, new StringBuilder().Append(from._where.ToString())); toType.GetField("_params", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, new List(from._params.ToArray())); - toType.GetField("_tables", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, new List(from._tables.ToArray())); + //toType.GetField("_tables", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, new List(from._tables.ToArray())); + var _multiTables = toType.GetField("_tables", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(to) as List; + _multiTables[0] = from._tables[0]; + for (var a = 1;a < lambParms.Count; a++) { + var tb = from._tables.Where(b => b.Alias == lambParms[a].Name && b.Table.Type == lambParms[a].Type).FirstOrDefault(); + if (tb != null) _multiTables[a] = tb; + else { + _multiTables[a].Alias = lambParms[a].Name; + _multiTables[a].Parameter = lambParms[a]; + } + } + if (_multiTables.Count < from._tables.Count) + _multiTables.AddRange(from._tables.GetRange(_multiTables.Count, from._tables.Count - _multiTables.Count)); toType.GetField("_tableRules", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._tableRules); toType.GetField("_join", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, new StringBuilder().Append(from._join.ToString())); toType.GetField("_cache", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._cache); @@ -97,12 +110,35 @@ namespace FreeSql.Internal.CommonProvider { return this as TSelect; } - public TSelect LeftJoin(Expression> exp) => this.InternalJoin(exp?.Body, SelectTableInfoType.LeftJoin); - public TSelect InnerJoin(Expression> exp) => this.InternalJoin(exp?.Body, SelectTableInfoType.InnerJoin); - public TSelect RightJoin(Expression> exp) => this.InternalJoin(exp?.Body, SelectTableInfoType.RightJoin); - public TSelect LeftJoin(Expression> exp) => this.InternalJoin(exp?.Body, SelectTableInfoType.LeftJoin); - public TSelect InnerJoin(Expression> exp) => this.InternalJoin(exp?.Body, SelectTableInfoType.InnerJoin); - public TSelect RightJoin(Expression> exp) => this.InternalJoin(exp?.Body, SelectTableInfoType.RightJoin); + public TSelect LeftJoin(Expression> exp) { + if (exp == null) return this as TSelect; + _tables[0].Parameter = exp.Parameters[0]; + return this.InternalJoin(exp?.Body, SelectTableInfoType.LeftJoin); + } + public TSelect InnerJoin(Expression> exp) { + if (exp == null) return this as TSelect; + _tables[0].Parameter = exp.Parameters[0]; + return this.InternalJoin(exp?.Body, SelectTableInfoType.InnerJoin); + } + public TSelect RightJoin(Expression> exp) { + if (exp == null) return this as TSelect; _tables[0].Parameter = exp.Parameters[0]; + return this.InternalJoin(exp?.Body, SelectTableInfoType.RightJoin); + } + public TSelect LeftJoin(Expression> exp) { + if (exp == null) return this as TSelect; + _tables[0].Parameter = exp.Parameters[0]; + return this.InternalJoin(exp?.Body, SelectTableInfoType.LeftJoin); + } + public TSelect InnerJoin(Expression> exp) { + if (exp == null) return this as TSelect; + _tables[0].Parameter = exp.Parameters[0]; + return this.InternalJoin(exp?.Body, SelectTableInfoType.InnerJoin); + } + public TSelect RightJoin(Expression> exp) { + if (exp == null) return this as TSelect; + _tables[0].Parameter = exp.Parameters[0]; + return this.InternalJoin(exp?.Body, SelectTableInfoType.RightJoin); + } public TSelect InnerJoin(string sql, object parms = null) { if (string.IsNullOrEmpty(sql)) return this as TSelect; diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select10Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select10Provider.cs index e2da2629..5626d807 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select10Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select10Provider.cs @@ -1,4 +1,5 @@ -using System; +using FreeSql.Internal.Model; +using System; using System.Collections.Generic; using System.Data; using System.Linq.Expressions; @@ -20,50 +21,148 @@ namespace FreeSql.Internal.CommonProvider { public Select10Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10)); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T7)), Alias = $"SP10g", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T8)), Alias = $"SP10h", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T9)), Alias = $"SP10i", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T10)), Alias = $"SP10j", On = null, Type = SelectTableInfoType.From }); } - TMember ISelect.Avg(Expression> column) => this.InternalAvg(column?.Body); + TMember ISelect.Avg(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvg(column?.Body); + } - Task ISelect.AvgAsync(Expression> column) => this.InternalAvgAsync(column?.Body); + Task ISelect.AvgAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvgAsync(column?.Body); + } - ISelectGrouping ISelect.GroupBy(Expression> exp) => this.InternalGroupBy(exp?.Body); + ISelectGrouping ISelect.GroupBy(Expression> exp) { + if (exp == null) return this.InternalGroupBy(exp?.Body); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.InternalGroupBy(exp?.Body); + } - TMember ISelect.Max(Expression> column) => this.InternalMax(column?.Body); + TMember ISelect.Max(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMax(column?.Body); + } - Task ISelect.MaxAsync(Expression> column) => this.InternalMaxAsync(column?.Body); + Task ISelect.MaxAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMaxAsync(column?.Body); + } - TMember ISelect.Min(Expression> column) => this.InternalMin(column?.Body); + TMember ISelect.Min(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMin(column?.Body); + } - Task ISelect.MinAsync(Expression> column) => this.InternalMinAsync(column?.Body); + Task ISelect.MinAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMinAsync(column?.Body); + } - ISelect ISelect.OrderBy(Expression> column) => this.InternalOrderBy(column?.Body); + ISelect ISelect.OrderBy(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderBy(column?.Body); + } - ISelect ISelect.OrderByDescending(Expression> column) => this.InternalOrderByDescending(column?.Body); + ISelect ISelect.OrderByDescending(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderByDescending(column?.Body); + } - TMember ISelect.Sum(Expression> column) => this.InternalSum(column?.Body); + TMember ISelect.Sum(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSum(column?.Body); + } - Task ISelect.SumAsync(Expression> column) => this.InternalSumAsync(column?.Body); + Task ISelect.SumAsync(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSumAsync(column?.Body); + } - TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregate(select?.Body); + TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return default(TReturn); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregate(select?.Body); + } - Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregateAsync(select?.Body); + Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return Task.FromResult(default(TReturn)); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregateAsync(select?.Body); + } - List ISelect.ToList(Expression> select) => this.InternalToList(select?.Body); + List ISelect.ToList(Expression> select) { + if (select == null) return this.InternalToList(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToList(select?.Body); + } - Task> ISelect.ToListAsync(Expression> select) => this.InternalToListAsync(select?.Body); + Task> ISelect.ToListAsync(Expression> select) { + if (select == null) return this.InternalToListAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToListAsync(select?.Body); + } - DataTable ISelect.ToDataTable(Expression> select) => this.InternalToDataTable(select?.Body); + DataTable ISelect.ToDataTable(Expression> select) { + if (select == null) return this.InternalToDataTable(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTable(select?.Body); + } - Task ISelect.ToDataTableAsync(Expression> select) => this.InternalToDataTableAsync(select?.Body); + Task ISelect.ToDataTableAsync(Expression> select) { + if (select == null) return this.InternalToDataTableAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTableAsync(select?.Body); + } - string ISelect.ToSql(Expression> select) => this.InternalToSql(select?.Body); + string ISelect.ToSql(Expression> select) { + if (select == null) return this.InternalToSql(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToSql(select?.Body); + } - ISelect ISelect.Where(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + ISelect ISelect.Where(Expression> exp) { + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + } - ISelect ISelect.WhereIf(bool condition, Expression> exp) => condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + ISelect ISelect.WhereIf(bool condition, Expression> exp) { + if (condition) return this.Where(null); + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + } - bool ISelect.Any(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + bool ISelect.Any(Expression> exp) { + if (exp == null) return this.Any(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + } - Task ISelect.AnyAsync(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + Task ISelect.AnyAsync(Expression> exp) { + if (exp == null) return this.AnyAsync(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + } } } \ No newline at end of file diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs index dee88c95..b01a94d6 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs @@ -58,70 +58,172 @@ namespace FreeSql.Internal.CommonProvider { return this; } - public TMember Avg(Expression> column) => this.InternalAvg(column?.Body); + public TMember Avg(Expression> column) { + if (column == null) return default(TMember); + _tables[0].Parameter = column.Parameters[0]; + return this.InternalAvg(column?.Body); + } - public Task AvgAsync(Expression> column) => this.InternalAvgAsync(column?.Body); + public Task AvgAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + _tables[0].Parameter = column.Parameters[0]; + return this.InternalAvgAsync(column?.Body); + } - public abstract ISelect From(Expression, T2, T3, ISelectFromExpression>> exp) where T2 : class where T3 : class;// { this.InternalFrom(exp?.Body); var ret = new Select3Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret); return ret; } + public abstract ISelect From(Expression, T2, T3, ISelectFromExpression>> exp) where T2 : class where T3 : class;// { this.InternalFrom(exp?.Body); var ret = new Select3Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret, exp?.Parameters); return ret; } - public abstract ISelect From(Expression, T2, T3, T4, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class;// { this.InternalFrom(exp?.Body); var ret = new Select4Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret); return ret; } + public abstract ISelect From(Expression, T2, T3, T4, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class;// { this.InternalFrom(exp?.Body); var ret = new Select4Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret, exp?.Parameters); return ret; } - public abstract ISelect From(Expression, T2, T3, T4, T5, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class;// { this.InternalFrom(exp?.Body); var ret = new Select5Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret); return ret; } + public abstract ISelect From(Expression, T2, T3, T4, T5, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class;// { this.InternalFrom(exp?.Body); var ret = new Select5Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret, exp?.Parameters); return ret; } - public abstract ISelect From(Expression, T2, T3, T4, T5, T6, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class;// { this.InternalFrom(exp?.Body); var ret = new Select6Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret); return ret; } + public abstract ISelect From(Expression, T2, T3, T4, T5, T6, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class;// { this.InternalFrom(exp?.Body); var ret = new Select6Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret, exp?.Parameters); return ret; } - public abstract ISelect From(Expression, T2, T3, T4, T5, T6, T7, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class;// { this.InternalFrom(exp?.Body); var ret = new Select7Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret); return ret; } + public abstract ISelect From(Expression, T2, T3, T4, T5, T6, T7, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class;// { this.InternalFrom(exp?.Body); var ret = new Select7Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret, exp?.Parameters); return ret; } - public abstract ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class;// { this.InternalFrom(exp?.Body); var ret = new Select8Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret); return ret; } + public abstract ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class;// { this.InternalFrom(exp?.Body); var ret = new Select8Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret, exp?.Parameters); return ret; } - public abstract ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class;// { this.InternalFrom(exp?.Body); var ret = new Select9Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret); return ret; } + public abstract ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class;// { this.InternalFrom(exp?.Body); var ret = new Select9Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret, exp?.Parameters); return ret; } - public abstract ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class;// { this.InternalFrom(exp?.Body); var ret = new Select10Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret); return ret; } + public abstract ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class;// { this.InternalFrom(exp?.Body); var ret = new Select10Provider(_orm, _commonUtils, _commonExpression, null); Select0Provider, T1>.CopyData(this, ret, exp?.Parameters); return ret; } - public ISelectGrouping GroupBy(Expression> columns) => this.InternalGroupBy(columns); + public ISelectGrouping GroupBy(Expression> columns) { + if (columns == null) return this.InternalGroupBy(columns); + _tables[0].Parameter = columns.Parameters[0]; + return this.InternalGroupBy(columns); + } - public TMember Max(Expression> column) => this.InternalMax(column?.Body); + public TMember Max(Expression> column) { + if (column == null) return default(TMember); + _tables[0].Parameter = column.Parameters[0]; + return this.InternalMax(column?.Body); + } - public Task MaxAsync(Expression> column) => this.InternalMaxAsync(column?.Body); + public Task MaxAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + _tables[0].Parameter = column.Parameters[0]; + return this.InternalMaxAsync(column?.Body); + } - public TMember Min(Expression> column) => this.InternalMin(column?.Body); + public TMember Min(Expression> column) { + if (column == null) return default(TMember); + _tables[0].Parameter = column.Parameters[0]; + return this.InternalMin(column?.Body); + } - public Task MinAsync(Expression> column) => this.InternalMinAsync(column?.Body); + public Task MinAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + _tables[0].Parameter = column.Parameters[0]; + return this.InternalMinAsync(column?.Body); + } - public ISelect OrderBy(Expression> column) => this.InternalOrderBy(column?.Body); + public ISelect OrderBy(Expression> column) { + if (column == null) return this; + _tables[0].Parameter = column.Parameters[0]; + return this.InternalOrderBy(column?.Body); + } - public ISelect OrderByDescending(Expression> column) => this.InternalOrderByDescending(column?.Body); + public ISelect OrderByDescending(Expression> column) { + if (column == null) return this; + _tables[0].Parameter = column.Parameters[0]; + return this.InternalOrderByDescending(column?.Body); + } - public TMember Sum(Expression> column) => this.InternalSum(column?.Body); + public TMember Sum(Expression> column) { + if (column == null) return default(TMember); + _tables[0].Parameter = column.Parameters[0]; + return this.InternalSum(column?.Body); + } - public Task SumAsync(Expression> column) => this.InternalSumAsync(column?.Body); + public Task SumAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + _tables[0].Parameter = column.Parameters[0]; + return this.InternalSumAsync(column?.Body); + } - public List ToList(Expression> select) => this.InternalToList(select?.Body); + public List ToList(Expression> select) { + if (select == null) return this.InternalToList(select?.Body); + _tables[0].Parameter = select.Parameters[0]; + return this.InternalToList(select?.Body); + } - public Task> ToListAsync(Expression> select) => this.InternalToListAsync(select?.Body); + public Task> ToListAsync(Expression> select) { + if (select == null) return this.InternalToListAsync(select?.Body); + _tables[0].Parameter = select.Parameters[0]; + return this.InternalToListAsync(select?.Body); + } - public DataTable ToDataTable(Expression> select) => this.InternalToDataTable(select?.Body); + public DataTable ToDataTable(Expression> select) { + if (select == null) return this.InternalToDataTable(select?.Body); + _tables[0].Parameter = select.Parameters[0]; + return this.InternalToDataTable(select?.Body); + } - public Task ToDataTableAsync(Expression> select) => this.InternalToDataTableAsync(select?.Body); + public Task ToDataTableAsync(Expression> select) { + if (select == null) return this.InternalToDataTableAsync(select?.Body); + _tables[0].Parameter = select.Parameters[0]; + return this.InternalToDataTableAsync(select?.Body); + } - public string ToSql(Expression> select) => this.InternalToSql(select?.Body); + public string ToSql(Expression> select) { + if (select == null) return this.InternalToSql(select?.Body); + _tables[0].Parameter = select.Parameters[0]; + return this.InternalToSql(select?.Body); + } - public TReturn ToAggregate(Expression, TReturn>> select) => this.InternalToAggregate(select?.Body); + public TReturn ToAggregate(Expression, TReturn>> select) { + if (select == null) return default(TReturn); + _tables[0].Parameter = select.Parameters[0]; + return this.InternalToAggregate(select?.Body); + } - public Task ToAggregateAsync(Expression, TReturn>> select) => this.InternalToAggregateAsync(select?.Body); + public Task ToAggregateAsync(Expression, TReturn>> select) { + if (select == null) return Task.FromResult(default(TReturn)); + _tables[0].Parameter = select.Parameters[0]; + return this.InternalToAggregateAsync(select?.Body); + } - public ISelect Where(Expression> exp) => this.InternalWhere(exp?.Body); + public ISelect Where(Expression> exp) { + if (exp == null) return this; + _tables[0].Parameter = exp.Parameters[0]; + return this.InternalWhere(exp?.Body); + } - public ISelect Where(Expression> exp) where T2 : class => this.InternalWhere(exp?.Body); - public ISelect Where(Expression> exp) where T2 : class => this.InternalWhere(exp?.Body); + public ISelect Where(Expression> exp) where T2 : class { + if (exp == null) return this; + _tables[0].Parameter = exp.Parameters[0]; + return this.InternalWhere(exp?.Body); + } - public ISelect Where(Expression> exp) where T2 : class where T3 : class => this.InternalWhere(exp?.Body); + public ISelect Where(Expression> exp) where T2 : class { + if (exp == null) return this; + //_tables[0].Parameter = exp.Parameters[0]; + return this.InternalWhere(exp?.Body); + } - public ISelect Where(Expression> exp) where T2 : class where T3 : class where T4 : class => this.InternalWhere(exp?.Body); + public ISelect Where(Expression> exp) where T2 : class where T3 : class { + if (exp == null) return this; + _tables[0].Parameter = exp.Parameters[0]; + return this.InternalWhere(exp?.Body); + } - public ISelect Where(Expression> exp) where T2 : class where T3 : class where T4 : class where T5 : class => this.InternalWhere(exp?.Body); + public ISelect Where(Expression> exp) where T2 : class where T3 : class where T4 : class { + if (exp == null) return this; + _tables[0].Parameter = exp.Parameters[0]; + return this.InternalWhere(exp?.Body); + } - public ISelect WhereIf(bool condition, Expression> exp) => condition ? this.InternalWhere(exp?.Body) : this; + public ISelect Where(Expression> exp) where T2 : class where T3 : class where T4 : class where T5 : class { + if (exp == null) return this; + _tables[0].Parameter = exp.Parameters[0]; + return this.InternalWhere(exp?.Body); + } + + public ISelect WhereIf(bool condition, Expression> exp) { + if (condition == false) return this; + if (exp == null) return this; + _tables[0].Parameter = exp.Parameters[0]; + return this.InternalWhere(exp?.Body); + } public bool Any(Expression> exp) => this.Where(exp).Any(); diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select3Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select3Provider.cs index dabdf416..cbe773a9 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select3Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select3Provider.cs @@ -1,4 +1,5 @@ -using System; +using FreeSql.Internal.Model; +using System; using System.Collections.Generic; using System.Data; using System.Linq.Expressions; @@ -13,50 +14,141 @@ namespace FreeSql.Internal.CommonProvider { public Select3Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3)); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From }); } - TMember ISelect.Avg(Expression> column) => this.InternalAvg(column?.Body); + TMember ISelect.Avg(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvg(column?.Body); + } - Task ISelect.AvgAsync(Expression> column) => this.InternalAvgAsync(column?.Body); + Task ISelect.AvgAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvgAsync(column?.Body); + } - ISelectGrouping ISelect.GroupBy(Expression> exp) => this.InternalGroupBy(exp?.Body); + ISelectGrouping ISelect.GroupBy(Expression> exp) { + if (exp == null) return this.InternalGroupBy(exp?.Body); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.InternalGroupBy(exp?.Body); + } - TMember ISelect.Max(Expression> column) => this.InternalMax(column?.Body); + TMember ISelect.Max(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMax(column?.Body); + } - Task ISelect.MaxAsync(Expression> column) => this.InternalMaxAsync(column?.Body); + Task ISelect.MaxAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMaxAsync(column?.Body); + } - TMember ISelect.Min(Expression> column) => this.InternalMin(column?.Body); + TMember ISelect.Min(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMin(column?.Body); + } - Task ISelect.MinAsync(Expression> column) => this.InternalMinAsync(column?.Body); + Task ISelect.MinAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMinAsync(column?.Body); + } - ISelect ISelect.OrderBy(Expression> column) => this.InternalOrderBy(column?.Body); + ISelect ISelect.OrderBy(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderBy(column?.Body); + } - ISelect ISelect.OrderByDescending(Expression> column) => this.InternalOrderByDescending(column?.Body); + ISelect ISelect.OrderByDescending(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderByDescending(column?.Body); + } - TMember ISelect.Sum(Expression> column) => this.InternalSum(column?.Body); + TMember ISelect.Sum(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSum(column?.Body); + } - Task ISelect.SumAsync(Expression> column) => this.InternalSumAsync(column?.Body); + Task ISelect.SumAsync(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSumAsync(column?.Body); + } - TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregate(select?.Body); + TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return default(TReturn); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregate(select?.Body); + } - Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregateAsync(select?.Body); + Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return Task.FromResult(default(TReturn)); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregateAsync(select?.Body); + } - List ISelect.ToList(Expression> select) => this.InternalToList(select?.Body); + List ISelect.ToList(Expression> select) { + if (select == null) return this.InternalToList(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToList(select?.Body); + } - Task> ISelect.ToListAsync(Expression> select) => this.InternalToListAsync(select?.Body); + Task> ISelect.ToListAsync(Expression> select) { + if (select == null) return this.InternalToListAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToListAsync(select?.Body); + } - DataTable ISelect.ToDataTable(Expression> select) => this.InternalToDataTable(select?.Body); + DataTable ISelect.ToDataTable(Expression> select) { + if (select == null) return this.InternalToDataTable(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTable(select?.Body); + } - Task ISelect.ToDataTableAsync(Expression> select) => this.InternalToDataTableAsync(select?.Body); + Task ISelect.ToDataTableAsync(Expression> select) { + if (select == null) return this.InternalToDataTableAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTableAsync(select?.Body); + } - string ISelect.ToSql(Expression> select) => this.InternalToSql(select?.Body); + string ISelect.ToSql(Expression> select) { + if (select == null) return this.InternalToSql(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToSql(select?.Body); + } - ISelect ISelect.Where(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + ISelect ISelect.Where(Expression> exp) { + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + } - ISelect ISelect.WhereIf(bool condition, Expression> exp) => condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + ISelect ISelect.WhereIf(bool condition, Expression> exp) { + if (condition) return this.Where(null); + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + } - bool ISelect.Any(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + bool ISelect.Any(Expression> exp) { + if (exp == null) return this.Any(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + } - Task ISelect.AnyAsync(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + Task ISelect.AnyAsync(Expression> exp) { + if (exp == null) return this.AnyAsync(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + } } } \ No newline at end of file diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select4Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select4Provider.cs index d3aab7ac..2ca5524f 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select4Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select4Provider.cs @@ -1,4 +1,5 @@ -using System; +using FreeSql.Internal.Model; +using System; using System.Collections.Generic; using System.Data; using System.Linq.Expressions; @@ -14,50 +15,142 @@ namespace FreeSql.Internal.CommonProvider { public Select4Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4)); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From }); } - TMember ISelect.Avg(Expression> column) => this.InternalAvg(column?.Body); + TMember ISelect.Avg(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvg(column?.Body); + } - Task ISelect.AvgAsync(Expression> column) => this.InternalAvgAsync(column?.Body); + Task ISelect.AvgAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvgAsync(column?.Body); + } - ISelectGrouping ISelect.GroupBy(Expression> exp) => this.InternalGroupBy(exp?.Body); + ISelectGrouping ISelect.GroupBy(Expression> exp) { + if (exp == null) return this.InternalGroupBy(exp?.Body); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.InternalGroupBy(exp?.Body); + } - TMember ISelect.Max(Expression> column) => this.InternalMax(column?.Body); + TMember ISelect.Max(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMax(column?.Body); + } - Task ISelect.MaxAsync(Expression> column) => this.InternalMaxAsync(column?.Body); + Task ISelect.MaxAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMaxAsync(column?.Body); + } - TMember ISelect.Min(Expression> column) => this.InternalMin(column?.Body); + TMember ISelect.Min(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMin(column?.Body); + } - Task ISelect.MinAsync(Expression> column) => this.InternalMinAsync(column?.Body); + Task ISelect.MinAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMinAsync(column?.Body); + } - ISelect ISelect.OrderBy(Expression> column) => this.InternalOrderBy(column?.Body); + ISelect ISelect.OrderBy(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderBy(column?.Body); + } - ISelect ISelect.OrderByDescending(Expression> column) => this.InternalOrderByDescending(column?.Body); + ISelect ISelect.OrderByDescending(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderByDescending(column?.Body); + } - TMember ISelect.Sum(Expression> column) => this.InternalSum(column?.Body); + TMember ISelect.Sum(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSum(column?.Body); + } - Task ISelect.SumAsync(Expression> column) => this.InternalSumAsync(column?.Body); + Task ISelect.SumAsync(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSumAsync(column?.Body); + } - TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregate(select?.Body); + TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return default(TReturn); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregate(select?.Body); + } - Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregateAsync(select?.Body); + Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return Task.FromResult(default(TReturn)); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregateAsync(select?.Body); + } - List ISelect.ToList(Expression> select) => this.InternalToList(select?.Body); + List ISelect.ToList(Expression> select) { + if (select == null) return this.InternalToList(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToList(select?.Body); + } - Task> ISelect.ToListAsync(Expression> select) => this.InternalToListAsync(select?.Body); + Task> ISelect.ToListAsync(Expression> select) { + if (select == null) return this.InternalToListAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToListAsync(select?.Body); + } - DataTable ISelect.ToDataTable(Expression> select) => this.InternalToDataTable(select?.Body); + DataTable ISelect.ToDataTable(Expression> select) { + if (select == null) return this.InternalToDataTable(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTable(select?.Body); + } - Task ISelect.ToDataTableAsync(Expression> select) => this.InternalToDataTableAsync(select?.Body); + Task ISelect.ToDataTableAsync(Expression> select) { + if (select == null) return this.InternalToDataTableAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTableAsync(select?.Body); + } - string ISelect.ToSql(Expression> select) => this.InternalToSql(select?.Body); + string ISelect.ToSql(Expression> select) { + if (select == null) return this.InternalToSql(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToSql(select?.Body); + } - ISelect ISelect.Where(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + ISelect ISelect.Where(Expression> exp) { + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + } - ISelect ISelect.WhereIf(bool condition, Expression> exp) => condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + ISelect ISelect.WhereIf(bool condition, Expression> exp) { + if (condition) return this.Where(null); + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + } - bool ISelect.Any(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + bool ISelect.Any(Expression> exp) { + if (exp == null) return this.Any(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + } - Task ISelect.AnyAsync(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + Task ISelect.AnyAsync(Expression> exp) { + if (exp == null) return this.AnyAsync(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + } } } \ No newline at end of file diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select5Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select5Provider.cs index 5c22462b..b5a30e03 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select5Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select5Provider.cs @@ -1,4 +1,5 @@ -using System; +using FreeSql.Internal.Model; +using System; using System.Collections.Generic; using System.Data; using System.Linq.Expressions; @@ -15,50 +16,143 @@ namespace FreeSql.Internal.CommonProvider { public Select5Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5)); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From }); } - TMember ISelect.Avg(Expression> column) => this.InternalAvg(column?.Body); + TMember ISelect.Avg(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvg(column?.Body); + } - Task ISelect.AvgAsync(Expression> column) => this.InternalAvgAsync(column?.Body); + Task ISelect.AvgAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvgAsync(column?.Body); + } - ISelectGrouping ISelect.GroupBy(Expression> exp) => this.InternalGroupBy(exp?.Body); + ISelectGrouping ISelect.GroupBy(Expression> exp) { + if (exp == null) return this.InternalGroupBy(exp?.Body); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.InternalGroupBy(exp?.Body); + } - TMember ISelect.Max(Expression> column) => this.InternalMax(column?.Body); + TMember ISelect.Max(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMax(column?.Body); + } - Task ISelect.MaxAsync(Expression> column) => this.InternalMaxAsync(column?.Body); + Task ISelect.MaxAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMaxAsync(column?.Body); + } - TMember ISelect.Min(Expression> column) => this.InternalMin(column?.Body); + TMember ISelect.Min(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMin(column?.Body); + } - Task ISelect.MinAsync(Expression> column) => this.InternalMinAsync(column?.Body); + Task ISelect.MinAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMinAsync(column?.Body); + } - ISelect ISelect.OrderBy(Expression> column) => this.InternalOrderBy(column?.Body); + ISelect ISelect.OrderBy(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderBy(column?.Body); + } - ISelect ISelect.OrderByDescending(Expression> column) => this.InternalOrderByDescending(column?.Body); + ISelect ISelect.OrderByDescending(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderByDescending(column?.Body); + } - TMember ISelect.Sum(Expression> column) => this.InternalSum(column?.Body); + TMember ISelect.Sum(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSum(column?.Body); + } - Task ISelect.SumAsync(Expression> column) => this.InternalSumAsync(column?.Body); + Task ISelect.SumAsync(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSumAsync(column?.Body); + } - TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregate(select?.Body); + TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return default(TReturn); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregate(select?.Body); + } - Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregateAsync(select?.Body); + Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return Task.FromResult(default(TReturn)); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregateAsync(select?.Body); + } - List ISelect.ToList(Expression> select) => this.InternalToList(select?.Body); + List ISelect.ToList(Expression> select) { + if (select == null) return this.InternalToList(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToList(select?.Body); + } - Task> ISelect.ToListAsync(Expression> select) => this.InternalToListAsync(select?.Body); + Task> ISelect.ToListAsync(Expression> select) { + if (select == null) return this.InternalToListAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToListAsync(select?.Body); + } - DataTable ISelect.ToDataTable(Expression> select) => this.InternalToDataTable(select?.Body); + DataTable ISelect.ToDataTable(Expression> select) { + if (select == null) return this.InternalToDataTable(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTable(select?.Body); + } - Task ISelect.ToDataTableAsync(Expression> select) => this.InternalToDataTableAsync(select?.Body); + Task ISelect.ToDataTableAsync(Expression> select) { + if (select == null) return this.InternalToDataTableAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTableAsync(select?.Body); + } - string ISelect.ToSql(Expression> select) => this.InternalToSql(select?.Body); + string ISelect.ToSql(Expression> select) { + if (select == null) return this.InternalToSql(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToSql(select?.Body); + } - ISelect ISelect.Where(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + ISelect ISelect.Where(Expression> exp) { + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + } - ISelect ISelect.WhereIf(bool condition, Expression> exp) => condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + ISelect ISelect.WhereIf(bool condition, Expression> exp) { + if (condition) return this.Where(null); + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + } - bool ISelect.Any(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + bool ISelect.Any(Expression> exp) { + if (exp == null) return this.Any(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + } - Task ISelect.AnyAsync(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + Task ISelect.AnyAsync(Expression> exp) { + if (exp == null) return this.AnyAsync(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + } } } \ No newline at end of file diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select6Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select6Provider.cs index c7162446..7bb16dd3 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select6Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select6Provider.cs @@ -1,4 +1,5 @@ -using System; +using FreeSql.Internal.Model; +using System; using System.Collections.Generic; using System.Data; using System.Linq.Expressions; @@ -16,50 +17,144 @@ namespace FreeSql.Internal.CommonProvider { public Select6Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6)); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From }); } - TMember ISelect.Avg(Expression> column) => this.InternalAvg(column?.Body); + TMember ISelect.Avg(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvg(column?.Body); + } - Task ISelect.AvgAsync(Expression> column) => this.InternalAvgAsync(column?.Body); + Task ISelect.AvgAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvgAsync(column?.Body); + } - ISelectGrouping ISelect.GroupBy(Expression> exp) => this.InternalGroupBy(exp?.Body); + ISelectGrouping ISelect.GroupBy(Expression> exp) { + if (exp == null) return this.InternalGroupBy(exp?.Body); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.InternalGroupBy(exp?.Body); + } - TMember ISelect.Max(Expression> column) => this.InternalMax(column?.Body); + TMember ISelect.Max(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMax(column?.Body); + } - Task ISelect.MaxAsync(Expression> column) => this.InternalMaxAsync(column?.Body); + Task ISelect.MaxAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMaxAsync(column?.Body); + } - TMember ISelect.Min(Expression> column) => this.InternalMin(column?.Body); + TMember ISelect.Min(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMin(column?.Body); + } - Task ISelect.MinAsync(Expression> column) => this.InternalMinAsync(column?.Body); + Task ISelect.MinAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMinAsync(column?.Body); + } - ISelect ISelect.OrderBy(Expression> column) => this.InternalOrderBy(column?.Body); + ISelect ISelect.OrderBy(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderBy(column?.Body); + } - ISelect ISelect.OrderByDescending(Expression> column) => this.InternalOrderByDescending(column?.Body); + ISelect ISelect.OrderByDescending(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderByDescending(column?.Body); + } - TMember ISelect.Sum(Expression> column) => this.InternalSum(column?.Body); + TMember ISelect.Sum(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSum(column?.Body); + } - Task ISelect.SumAsync(Expression> column) => this.InternalSumAsync(column?.Body); + Task ISelect.SumAsync(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSumAsync(column?.Body); + } - TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregate(select?.Body); + TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return default(TReturn); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregate(select?.Body); + } - Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregateAsync(select?.Body); + Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return Task.FromResult(default(TReturn)); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregateAsync(select?.Body); + } - List ISelect.ToList(Expression> select) => this.InternalToList(select?.Body); + List ISelect.ToList(Expression> select) { + if (select == null) return this.InternalToList(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToList(select?.Body); + } - Task> ISelect.ToListAsync(Expression> select) => this.InternalToListAsync(select?.Body); + Task> ISelect.ToListAsync(Expression> select) { + if (select == null) return this.InternalToListAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToListAsync(select?.Body); + } - DataTable ISelect.ToDataTable(Expression> select) => this.InternalToDataTable(select?.Body); + DataTable ISelect.ToDataTable(Expression> select) { + if (select == null) return this.InternalToDataTable(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTable(select?.Body); + } - Task ISelect.ToDataTableAsync(Expression> select) => this.InternalToDataTableAsync(select?.Body); + Task ISelect.ToDataTableAsync(Expression> select) { + if (select == null) return this.InternalToDataTableAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTableAsync(select?.Body); + } - string ISelect.ToSql(Expression> select) => this.InternalToSql(select?.Body); + string ISelect.ToSql(Expression> select) { + if (select == null) return this.InternalToSql(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToSql(select?.Body); + } - ISelect ISelect.Where(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + ISelect ISelect.Where(Expression> exp) { + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + } - ISelect ISelect.WhereIf(bool condition, Expression> exp) => condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + ISelect ISelect.WhereIf(bool condition, Expression> exp) { + if (condition) return this.Where(null); + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + } - bool ISelect.Any(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + bool ISelect.Any(Expression> exp) { + if (exp == null) return this.Any(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + } - Task ISelect.AnyAsync(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + Task ISelect.AnyAsync(Expression> exp) { + if (exp == null) return this.AnyAsync(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + } } } \ No newline at end of file diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select7Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select7Provider.cs index 11f0c693..9fd1025e 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select7Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select7Provider.cs @@ -1,4 +1,5 @@ -using System; +using FreeSql.Internal.Model; +using System; using System.Collections.Generic; using System.Data; using System.Linq.Expressions; @@ -17,50 +18,145 @@ namespace FreeSql.Internal.CommonProvider { public Select7Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7)); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T7)), Alias = $"SP10g", On = null, Type = SelectTableInfoType.From }); } - TMember ISelect.Avg(Expression> column) => this.InternalAvg(column?.Body); + TMember ISelect.Avg(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvg(column?.Body); + } - Task ISelect.AvgAsync(Expression> column) => this.InternalAvgAsync(column?.Body); + Task ISelect.AvgAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvgAsync(column?.Body); + } - ISelectGrouping ISelect.GroupBy(Expression> exp) => this.InternalGroupBy(exp?.Body); + ISelectGrouping ISelect.GroupBy(Expression> exp) { + if (exp == null) return this.InternalGroupBy(exp?.Body); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.InternalGroupBy(exp?.Body); + } - TMember ISelect.Max(Expression> column) => this.InternalMax(column?.Body); + TMember ISelect.Max(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMax(column?.Body); + } - Task ISelect.MaxAsync(Expression> column) => this.InternalMaxAsync(column?.Body); + Task ISelect.MaxAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMaxAsync(column?.Body); + } - TMember ISelect.Min(Expression> column) => this.InternalMin(column?.Body); + TMember ISelect.Min(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMin(column?.Body); + } - Task ISelect.MinAsync(Expression> column) => this.InternalMinAsync(column?.Body); + Task ISelect.MinAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMinAsync(column?.Body); + } - ISelect ISelect.OrderBy(Expression> column) => this.InternalOrderBy(column?.Body); + ISelect ISelect.OrderBy(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderBy(column?.Body); + } - ISelect ISelect.OrderByDescending(Expression> column) => this.InternalOrderByDescending(column?.Body); + ISelect ISelect.OrderByDescending(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderByDescending(column?.Body); + } - TMember ISelect.Sum(Expression> column) => this.InternalSum(column?.Body); + TMember ISelect.Sum(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSum(column?.Body); + } - Task ISelect.SumAsync(Expression> column) => this.InternalSumAsync(column?.Body); + Task ISelect.SumAsync(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSumAsync(column?.Body); + } - TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregate(select?.Body); + TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return default(TReturn); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregate(select?.Body); + } - Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregateAsync(select?.Body); + Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return Task.FromResult(default(TReturn)); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregateAsync(select?.Body); + } - List ISelect.ToList(Expression> select) => this.InternalToList(select?.Body); + List ISelect.ToList(Expression> select) { + if (select == null) return this.InternalToList(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToList(select?.Body); + } - Task> ISelect.ToListAsync(Expression> select) => this.InternalToListAsync(select?.Body); + Task> ISelect.ToListAsync(Expression> select) { + if (select == null) return this.InternalToListAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToListAsync(select?.Body); + } - DataTable ISelect.ToDataTable(Expression> select) => this.InternalToDataTable(select?.Body); + DataTable ISelect.ToDataTable(Expression> select) { + if (select == null) return this.InternalToDataTable(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTable(select?.Body); + } - Task ISelect.ToDataTableAsync(Expression> select) => this.InternalToDataTableAsync(select?.Body); + Task ISelect.ToDataTableAsync(Expression> select) { + if (select == null) return this.InternalToDataTableAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTableAsync(select?.Body); + } - string ISelect.ToSql(Expression> select) => this.InternalToSql(select?.Body); + string ISelect.ToSql(Expression> select) { + if (select == null) return this.InternalToSql(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToSql(select?.Body); + } - ISelect ISelect.Where(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + ISelect ISelect.Where(Expression> exp) { + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + } - ISelect ISelect.WhereIf(bool condition, Expression> exp) => condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + ISelect ISelect.WhereIf(bool condition, Expression> exp) { + if (condition) return this.Where(null); + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + } - bool ISelect.Any(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + bool ISelect.Any(Expression> exp) { + if (exp == null) return this.Any(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + } - Task ISelect.AnyAsync(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + Task ISelect.AnyAsync(Expression> exp) { + if (exp == null) return this.AnyAsync(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + } } } \ No newline at end of file diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select8Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select8Provider.cs index c190aeda..5dbcaf8a 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select8Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select8Provider.cs @@ -1,4 +1,5 @@ -using System; +using FreeSql.Internal.Model; +using System; using System.Collections.Generic; using System.Data; using System.Linq.Expressions; @@ -18,50 +19,146 @@ namespace FreeSql.Internal.CommonProvider { public Select8Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8)); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T7)), Alias = $"SP10g", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T8)), Alias = $"SP10h", On = null, Type = SelectTableInfoType.From }); } - TMember ISelect.Avg(Expression> column) => this.InternalAvg(column?.Body); + TMember ISelect.Avg(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvg(column?.Body); + } - Task ISelect.AvgAsync(Expression> column) => this.InternalAvgAsync(column?.Body); + Task ISelect.AvgAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvgAsync(column?.Body); + } - ISelectGrouping ISelect.GroupBy(Expression> exp) => this.InternalGroupBy(exp?.Body); + ISelectGrouping ISelect.GroupBy(Expression> exp) { + if (exp == null) return this.InternalGroupBy(exp?.Body); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.InternalGroupBy(exp?.Body); + } - TMember ISelect.Max(Expression> column) => this.InternalMax(column?.Body); + TMember ISelect.Max(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMax(column?.Body); + } - Task ISelect.MaxAsync(Expression> column) => this.InternalMaxAsync(column?.Body); + Task ISelect.MaxAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMaxAsync(column?.Body); + } - TMember ISelect.Min(Expression> column) => this.InternalMin(column?.Body); + TMember ISelect.Min(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMin(column?.Body); + } - Task ISelect.MinAsync(Expression> column) => this.InternalMinAsync(column?.Body); + Task ISelect.MinAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMinAsync(column?.Body); + } - ISelect ISelect.OrderBy(Expression> column) => this.InternalOrderBy(column?.Body); + ISelect ISelect.OrderBy(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderBy(column?.Body); + } - ISelect ISelect.OrderByDescending(Expression> column) => this.InternalOrderByDescending(column?.Body); + ISelect ISelect.OrderByDescending(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderByDescending(column?.Body); + } - TMember ISelect.Sum(Expression> column) => this.InternalSum(column?.Body); + TMember ISelect.Sum(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSum(column?.Body); + } - Task ISelect.SumAsync(Expression> column) => this.InternalSumAsync(column?.Body); + Task ISelect.SumAsync(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSumAsync(column?.Body); + } - TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregate(select?.Body); + TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return default(TReturn); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregate(select?.Body); + } - Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregateAsync(select?.Body); + Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return Task.FromResult(default(TReturn)); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregateAsync(select?.Body); + } - List ISelect.ToList(Expression> select) => this.InternalToList(select?.Body); + List ISelect.ToList(Expression> select) { + if (select == null) return this.InternalToList(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToList(select?.Body); + } - Task> ISelect.ToListAsync(Expression> select) => this.InternalToListAsync(select?.Body); + Task> ISelect.ToListAsync(Expression> select) { + if (select == null) return this.InternalToListAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToListAsync(select?.Body); + } - DataTable ISelect.ToDataTable(Expression> select) => this.InternalToDataTable(select?.Body); + DataTable ISelect.ToDataTable(Expression> select) { + if (select == null) return this.InternalToDataTable(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTable(select?.Body); + } - Task ISelect.ToDataTableAsync(Expression> select) => this.InternalToDataTableAsync(select?.Body); + Task ISelect.ToDataTableAsync(Expression> select) { + if (select == null) return this.InternalToDataTableAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTableAsync(select?.Body); + } - string ISelect.ToSql(Expression> select) => this.InternalToSql(select?.Body); + string ISelect.ToSql(Expression> select) { + if (select == null) return this.InternalToSql(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToSql(select?.Body); + } - ISelect ISelect.Where(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + ISelect ISelect.Where(Expression> exp) { + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + } - ISelect ISelect.WhereIf(bool condition, Expression> exp) => condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + ISelect ISelect.WhereIf(bool condition, Expression> exp) { + if (condition) return this.Where(null); + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + } - bool ISelect.Any(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + bool ISelect.Any(Expression> exp) { + if (exp == null) return this.Any(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + } - Task ISelect.AnyAsync(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + Task ISelect.AnyAsync(Expression> exp) { + if (exp == null) return this.AnyAsync(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + } } } \ No newline at end of file diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select9Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select9Provider.cs index 1b214054..4f1b042a 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select9Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select9Provider.cs @@ -1,4 +1,5 @@ -using System; +using FreeSql.Internal.Model; +using System; using System.Collections.Generic; using System.Data; using System.Linq.Expressions; @@ -19,50 +20,147 @@ namespace FreeSql.Internal.CommonProvider { public Select9Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9)); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T7)), Alias = $"SP10g", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T8)), Alias = $"SP10h", On = null, Type = SelectTableInfoType.From }); + _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T9)), Alias = $"SP10i", On = null, Type = SelectTableInfoType.From }); } - TMember ISelect.Avg(Expression> column) => this.InternalAvg(column?.Body); + TMember ISelect.Avg(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvg(column?.Body); + } - Task ISelect.AvgAsync(Expression> column) => this.InternalAvgAsync(column?.Body); + Task ISelect.AvgAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvgAsync(column?.Body); + } - ISelectGrouping ISelect.GroupBy(Expression> exp) => this.InternalGroupBy(exp?.Body); + ISelectGrouping ISelect.GroupBy(Expression> exp) { + if (exp == null) return this.InternalGroupBy(exp?.Body); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.InternalGroupBy(exp?.Body); + } - TMember ISelect.Max(Expression> column) => this.InternalMax(column?.Body); + TMember ISelect.Max(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMax(column?.Body); + } - Task ISelect.MaxAsync(Expression> column) => this.InternalMaxAsync(column?.Body); + Task ISelect.MaxAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMaxAsync(column?.Body); + } - TMember ISelect.Min(Expression> column) => this.InternalMin(column?.Body); + TMember ISelect.Min(Expression> column) { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMin(column?.Body); + } - Task ISelect.MinAsync(Expression> column) => this.InternalMinAsync(column?.Body); + Task ISelect.MinAsync(Expression> column) { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMinAsync(column?.Body); + } - ISelect ISelect.OrderBy(Expression> column) => this.InternalOrderBy(column?.Body); + ISelect ISelect.OrderBy(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderBy(column?.Body); + } - ISelect ISelect.OrderByDescending(Expression> column) => this.InternalOrderByDescending(column?.Body); + ISelect ISelect.OrderByDescending(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderByDescending(column?.Body); + } - TMember ISelect.Sum(Expression> column) => this.InternalSum(column?.Body); + TMember ISelect.Sum(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSum(column?.Body); + } - Task ISelect.SumAsync(Expression> column) => this.InternalSumAsync(column?.Body); + Task ISelect.SumAsync(Expression> column) { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSumAsync(column?.Body); + } - TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregate(select?.Body); + TReturn ISelect.ToAggregate(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return default(TReturn); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregate(select?.Body); + } - Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) => this.InternalToAggregateAsync(select?.Body); + Task ISelect.ToAggregateAsync(Expression, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, ISelectGroupingAggregate, TReturn>> select) { + if (select == null) return Task.FromResult(default(TReturn)); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregateAsync(select?.Body); + } - List ISelect.ToList(Expression> select) => this.InternalToList(select?.Body); + List ISelect.ToList(Expression> select) { + if (select == null) return this.InternalToList(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToList(select?.Body); + } - Task> ISelect.ToListAsync(Expression> select) => this.InternalToListAsync(select?.Body); + Task> ISelect.ToListAsync(Expression> select) { + if (select == null) return this.InternalToListAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToListAsync(select?.Body); + } - DataTable ISelect.ToDataTable(Expression> select) => this.InternalToDataTable(select?.Body); + DataTable ISelect.ToDataTable(Expression> select) { + if (select == null) return this.InternalToDataTable(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTable(select?.Body); + } - Task ISelect.ToDataTableAsync(Expression> select) => this.InternalToDataTableAsync(select?.Body); + Task ISelect.ToDataTableAsync(Expression> select) { + if (select == null) return this.InternalToDataTableAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTableAsync(select?.Body); + } - string ISelect.ToSql(Expression> select) => this.InternalToSql(select?.Body); + string ISelect.ToSql(Expression> select) { + if (select == null) return this.InternalToSql(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToSql(select?.Body); + } - ISelect ISelect.Where(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + ISelect ISelect.Where(Expression> exp) { + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)); + } - ISelect ISelect.WhereIf(bool condition, Expression> exp) => condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + ISelect ISelect.WhereIf(bool condition, Expression> exp) { + if (condition) return this.Where(null); + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this; + } - bool ISelect.Any(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + bool ISelect.Any(Expression> exp) { + if (exp == null) return this.Any(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any(); + } - Task ISelect.AnyAsync(Expression> exp) => this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + Task ISelect.AnyAsync(Expression> exp) { + if (exp == null) return this.AnyAsync(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync(); + } } } \ No newline at end of file diff --git a/FreeSql/Internal/Model/SelectTableInfo.cs b/FreeSql/Internal/Model/SelectTableInfo.cs index d01cd3f1..0aa138f2 100644 --- a/FreeSql/Internal/Model/SelectTableInfo.cs +++ b/FreeSql/Internal/Model/SelectTableInfo.cs @@ -1,8 +1,12 @@ -namespace FreeSql.Internal.Model { +using System.Linq.Expressions; + +namespace FreeSql.Internal.Model { class SelectTableInfo { public TableInfo Table { get; set; } public string Alias { get; set; } public string On { get; set; } + public string NavigateCondition { get; set; } + public ParameterExpression Parameter { get; set; } public SelectTableInfoType Type { get; set; } } enum SelectTableInfoType { From, LeftJoin, InnerJoin, RightJoin, Parent } diff --git a/FreeSql/Internal/Model/TableInfo.cs b/FreeSql/Internal/Model/TableInfo.cs index fc8195cd..1d29f2b0 100644 --- a/FreeSql/Internal/Model/TableInfo.cs +++ b/FreeSql/Internal/Model/TableInfo.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Reflection; @@ -15,5 +16,38 @@ namespace FreeSql.Internal.Model { public string DbName { get; set; } public string DbOldName { get; set; } public string SelectFilter { get; set; } + + + ConcurrentDictionary _refs { get; } = new ConcurrentDictionary(StringComparer.CurrentCultureIgnoreCase); + + internal void AddOrUpdateTableRef(string propertyName, TableRef tbref) { + _refs.AddOrUpdate(propertyName, tbref, (ok, ov) => tbref); + } + internal TableRef GetTableRef(string propertyName) { + if (_refs.TryGetValue(propertyName, out var tryref) == false) return null; + if (tryref.Exception != null) throw tryref.Exception; + return tryref; + } + } + + internal class TableRef { + public PropertyInfo Property { get; set; } + + public TableRefType RefType { get; set; } + + public Type RefEntityType { get; set; } + /// + /// 中间表,多对多 + /// + public Type RefMiddleEntityType { get; set; } + + public List Columns { get; set; } = new List(); + public List MiddleColumns { get; set; } = new List(); + public List RefColumns { get; set; } = new List(); + + public Exception Exception { get; set; } + } + internal enum TableRefType { + OneToOne, ManyToOne, OneToMany, ManyToMany } } \ No newline at end of file diff --git a/FreeSql/Internal/UtilsExpressionTree.cs b/FreeSql/Internal/UtilsExpressionTree.cs index 1a4afe21..e2589d3c 100644 --- a/FreeSql/Internal/UtilsExpressionTree.cs +++ b/FreeSql/Internal/UtilsExpressionTree.cs @@ -2,6 +2,7 @@ using FreeSql.Internal.Model; using Newtonsoft.Json.Linq; using System; +using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Data.Common; @@ -25,6 +26,7 @@ namespace FreeSql.Internal { var tbc = _cacheGetTableByEntity.GetOrAdd(common._orm.Ado.DataType, k1 => new ConcurrentDictionary()); //区分数据库类型缓存 if (tbc.TryGetValue(entity, out var trytb)) return trytb; if (common.CodeFirst.GetDbInfo(entity) != null) return null; + if (typeof(IEnumerable).IsAssignableFrom(entity)) return null; var tbattr = common.GetEntityTableAttribute(entity); trytb = new TableInfo(); @@ -43,6 +45,7 @@ namespace FreeSql.Internal { } trytb.SelectFilter = tbattr?.SelectFilter; var propsLazy = new List<(PropertyInfo, bool, bool)>(); + var propsNavObjs = new List(); foreach (var p in trytb.Properties.Values) { var tp = common.CodeFirst.GetDbInfo(p.PropertyType); //if (tp == null) continue; @@ -54,6 +57,7 @@ namespace FreeSql.Internal { if (getIsVirtual == true || setIsVirtual == true) propsLazy.Add((p, getIsVirtual == true, setIsVirtual == true)); } + propsNavObjs.Add(p); continue; } if (colattr == null) @@ -148,14 +152,17 @@ namespace FreeSql.Internal { } tbc.AddOrUpdate(entity, trytb, (oldkey, oldval) => trytb); - #region virtual 属性延时加载,动态产生新的重写类 + #region 查找导航属性的关系、virtual 属性延时加载,动态产生新的重写类 + var trytbTypeName = trytb.Type.IsNested ? $"{trytb.Type.DeclaringType.Namespace}.{trytb.Type.DeclaringType.Name}.{trytb.Type.Name}" : $"{trytb.Type.Namespace}.{trytb.Type.Name}"; + var trytbTypeLazyName = default(string); + var overrieds = 0; + StringBuilder cscode = null; if (common.CodeFirst.IsLazyLoading && propsLazy.Any()) { - var trytbTypeName = trytb.Type.IsNested ? $"{trytb.Type.DeclaringType.Namespace}.{trytb.Type.DeclaringType.Name}.{trytb.Type.Name}" : $"{trytb.Type.Namespace}.{trytb.Type.Name}"; if (trytb.Type.IsPublic == false && trytb.Type.IsNestedPublic == false) throw new Exception($"【延时加载】实体类型 {trytbTypeName} 必须声明为 public"); - var trytbTypeLazyName = $"FreeSqlLazyEntity__{Regex.Replace(trytbTypeName, @"[^\w\d]", "_")}"; - var overrieds = 0; - var cscode = new StringBuilder(); + trytbTypeLazyName = $"FreeSqlLazyEntity__{Regex.Replace(trytbTypeName, @"[^\w\d]", "_")}"; + + cscode = new StringBuilder(); cscode.AppendLine("using System;") .AppendLine("using FreeSql.DataAnnotations;") .AppendLine("using System.Collections.Generic;") @@ -164,211 +171,269 @@ namespace FreeSql.Internal { .AppendLine() .Append("public class ").Append(trytbTypeLazyName).Append(" : ").Append(trytbTypeName).AppendLine(" {") .AppendLine(" [JsonIgnore] private IFreeSql __fsql_orm__ { get; set; }\r\n"); + } - foreach (var vp in propsLazy) { - var propTypeName = vp.Item1.PropertyType.IsGenericType ? - $"{vp.Item1.PropertyType.Namespace}.{vp.Item1.PropertyType.Name.Remove(vp.Item1.PropertyType.Name.IndexOf('`'))}<{string.Join(", ", vp.Item1.PropertyType.GenericTypeArguments.Select(a => a.IsNested ? $"{a.DeclaringType.Namespace}.{a.DeclaringType.Name}.{a.Name}" : $"{a.Namespace}.{a.Name}"))}>" : - (vp.Item1.PropertyType.IsNested ? $"{vp.Item1.PropertyType.DeclaringType.Namespace}.{vp.Item1.PropertyType.DeclaringType.Name}.{vp.Item1.PropertyType.Name}" : $"{vp.Item1.PropertyType.Namespace}.{vp.Item1.PropertyType.Name}"); - //List 或 ICollection,一对多、多对多 - var propElementType = vp.Item1.PropertyType.GenericTypeArguments.FirstOrDefault() ?? vp.Item1.PropertyType.GetElementType(); - if (propElementType != null) { - if (vp.Item1.PropertyType.GetInterface("System.Collections.IEnumerable") == null) continue; + foreach(var pnv in propsNavObjs) { + var vp = propsLazy.Where(a => a.Item1 == pnv).FirstOrDefault(); + var isLazy = vp.Item1 != null && !string.IsNullOrEmpty(trytbTypeLazyName); + var propTypeName = pnv.PropertyType.IsGenericType ? + $"{pnv.PropertyType.Namespace}.{pnv.PropertyType.Name.Remove(pnv.PropertyType.Name.IndexOf('`'))}<{string.Join(", ", pnv.PropertyType.GenericTypeArguments.Select(a => a.IsNested ? $"{a.DeclaringType.Namespace}.{a.DeclaringType.Name}.{a.Name}" : $"{a.Namespace}.{a.Name}"))}>" : + (pnv.PropertyType.IsNested ? $"{pnv.PropertyType.DeclaringType.Namespace}.{pnv.PropertyType.DeclaringType.Name}.{pnv.PropertyType.Name}" : $"{pnv.PropertyType.Namespace}.{pnv.PropertyType.Name}"); - if (trytb.Primarys.Any() == false) { - //continue; - throw new Exception($"【延时加载】导航属性 {trytbTypeName}.{vp.Item1.Name} 解析错误,实体类型 {trytbTypeName} 缺少主键标识,[Column(IsPrimary = true)]"); + var nvref = new TableRef(); + nvref.Property = pnv; + + //List 或 ICollection,一对多、多对多 + var propElementType = pnv.PropertyType.GenericTypeArguments.FirstOrDefault() ?? pnv.PropertyType.GetElementType(); + if (propElementType != null) { + if (typeof(IEnumerable).IsAssignableFrom(pnv.PropertyType) == false) continue; + if (trytb.Primarys.Any() == false) { + nvref.Exception = new Exception($"导航属性 {trytbTypeName}.{pnv.Name} 解析错误,实体类型 {trytbTypeName} 缺少主键标识,[Column(IsPrimary = true)]"); + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + if (isLazy) throw nvref.Exception; + continue; + } + + var tbref = propElementType == trytb.Type ? trytb : GetTableByEntity(propElementType, common); //可能是父子关系 + if (tbref == null) continue; + + var tbrefTypeName = tbref.Type.IsNested ? $"{tbref.Type.DeclaringType.Namespace}.{tbref.Type.DeclaringType.Name}.{tbref.Type.Name}" : $"{tbref.Type.Namespace}.{tbref.Type.Name}"; + Type midType = null; + var isManyToMany = propElementType != trytb.Type && + pnv.Name.EndsWith($"{tbref.CsName}s") && + tbref.Properties.Where(z => (z.Value.PropertyType.GenericTypeArguments.FirstOrDefault() == trytb.Type || z.Value.PropertyType.GetElementType() == trytb.Type) && + z.Key.EndsWith($"{trytb.CsName}s", StringComparison.CurrentCultureIgnoreCase) && + typeof(IEnumerable).IsAssignableFrom(z.Value.PropertyType)).Any(); + if (isManyToMany) { + if (tbref.Primarys.Any() == false) { + nvref.Exception = new Exception($"【ManyToMany】导航属性 {trytbTypeName}.{pnv.Name} 解析错误,实体类型 {tbrefTypeName} 缺少主键标识,[Column(IsPrimary = true)]"); + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + if (isLazy) throw nvref.Exception; + continue; } - var tbref = propElementType == trytb.Type ? trytb : GetTableByEntity(propElementType, common); //可能是父子关系 - if (tbref == null) continue; - var tbrefTypeName = tbref.Type.IsNested ? $"{tbref.Type.DeclaringType.Namespace}.{tbref.Type.DeclaringType.Name}.{tbref.Type.Name}" : $"{tbref.Type.Namespace}.{tbref.Type.Name}"; - Type midType = null; - var isManyToMany = propElementType != trytb.Type && - vp.Item1.Name.EndsWith($"{tbref.CsName}s") && - tbref.Properties.Where(z => (z.Value.PropertyType.GenericTypeArguments.FirstOrDefault() == trytb.Type || z.Value.PropertyType.GetElementType() == trytb.Type) && - z.Key.EndsWith($"{trytb.CsName}s", StringComparison.CurrentCultureIgnoreCase) && - vp.Item1.PropertyType.GetInterface("System.Collections.IEnumerable") != null).Any(); - if (isManyToMany) { - if (tbref.Primarys.Any() == false) { - //continue; - throw new Exception($"【延时加载ManyToMany】导航属性 {trytbTypeName}.{vp.Item1.Name} 解析错误,实体类型 {tbrefTypeName} 缺少主键标识,[Column(IsPrimary = true)]"); - } - //中间表怎么查询,比如 Song、Tag、SongTag - var midFlagStr = vp.Item1.Name.Remove(vp.Item1.Name.Length - tbref.CsName.Length - 1); + //中间表怎么查询,比如 Song、Tag、SongTag + var midFlagStr = pnv.Name.Remove(pnv.Name.Length - tbref.CsName.Length - 1); - //在 trytb 命名空间下查找中间类 - midType = trytb.Type.IsNested ? - trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{trytb.Type.DeclaringType.Name}+{trytb.CsName}{tbref.CsName}{midFlagStr}", false, true) : //SongTag - trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{trytb.CsName}{tbref.CsName}{midFlagStr}", false, true); + #region 在 trytb 命名空间下查找中间类 + midType = trytb.Type.IsNested ? + trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{trytb.Type.DeclaringType.Name}+{trytb.CsName}{tbref.CsName}{midFlagStr}", false, true) : //SongTag + trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{trytb.CsName}{tbref.CsName}{midFlagStr}", false, true); + if (midType != null) { + var midTypeProps = midType.GetProperties(); + var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); + var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); + if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; + } + if (midType == null) { + midType = trytb.Type.IsNested ? + trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{trytb.Type.DeclaringType.Name}+{trytb.CsName}_{tbref.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true) : //Song_Tag + trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{trytb.CsName}_{tbref.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true); if (midType != null) { var midTypeProps = midType.GetProperties(); var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; } - if (midType == null) { - midType = trytb.Type.IsNested ? - trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{trytb.Type.DeclaringType.Name}+{trytb.CsName}_{tbref.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true) : //Song_Tag - trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{trytb.CsName}_{tbref.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true); - if (midType != null) { - var midTypeProps = midType.GetProperties(); - var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); - var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); - if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; - } - } - if (midType == null) { - midType = trytb.Type.IsNested ? - trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{trytb.Type.DeclaringType.Name}+{tbref.CsName}{trytb.CsName}{midFlagStr}", false, true) : //TagSong - trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{tbref.CsName}{trytb.CsName}{midFlagStr}", false, true); - if (midType != null) { - var midTypeProps = midType.GetProperties(); - var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); - var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); - if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; - } - } - if (midType == null) { - midType = trytb.Type.IsNested ? - trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{trytb.Type.DeclaringType.Name}+{tbref.CsName}_{trytb.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true) : //Tag_Song - trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{tbref.CsName}_{trytb.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true); - if (midType != null) { - var midTypeProps = midType.GetProperties(); - var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); - var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); - if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; - } - } - - //在 tbref 命名空间下查找中间类 - if (midType == null) { - midType = tbref.Type.IsNested ? - tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{tbref.Type.DeclaringType.Name}+{trytb.CsName}{tbref.CsName}{midFlagStr}", false, true) : //SongTag - tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{trytb.CsName}{tbref.CsName}{midFlagStr}", false, true); - if (midType != null) { - var midTypeProps = midType.GetProperties(); - var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); - var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); - if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; - } - } - if (midType == null) { - midType = tbref.Type.IsNested ? - tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{tbref.Type.DeclaringType.Name}+{trytb.CsName}_{tbref.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true) : //Song_Tag - tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{trytb.CsName}_{tbref.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true); - if (midType != null) { - var midTypeProps = midType.GetProperties(); - var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); - var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); - if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; - } - } - if (midType == null) { - midType = tbref.Type.IsNested ? - tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{tbref.Type.DeclaringType.Name}+{tbref.CsName}{trytb.CsName}{midFlagStr}", false, true) : //TagSong - tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{tbref.CsName}{trytb.CsName}{midFlagStr}", false, true); - if (midType != null) { - var midTypeProps = midType.GetProperties(); - var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); - var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); - if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; - } - } - if (midType == null) { - midType = tbref.Type.IsNested ? - tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{tbref.Type.DeclaringType.Name}+{tbref.CsName}_{trytb.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true) : //Tag_Song - tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{tbref.CsName}_{trytb.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true); - if (midType != null) { - var midTypeProps = midType.GetProperties(); - var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); - var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); - if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; - } - } - isManyToMany = midType != null; } + if (midType == null) { + midType = trytb.Type.IsNested ? + trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{trytb.Type.DeclaringType.Name}+{tbref.CsName}{trytb.CsName}{midFlagStr}", false, true) : //TagSong + trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{tbref.CsName}{trytb.CsName}{midFlagStr}", false, true); + if (midType != null) { + var midTypeProps = midType.GetProperties(); + var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); + var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); + if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; + } + } + if (midType == null) { + midType = trytb.Type.IsNested ? + trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{trytb.Type.DeclaringType.Name}+{tbref.CsName}_{trytb.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true) : //Tag_Song + trytb.Type.Assembly.GetType($"{trytb.Type.Namespace}.{tbref.CsName}_{trytb.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true); + if (midType != null) { + var midTypeProps = midType.GetProperties(); + var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); + var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); + if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; + } + } + #endregion - if (isManyToMany) { - var tbmid = GetTableByEntity(midType, common); - var midTypePropsTrytb = tbmid.Properties.Where(a => a.Value.PropertyType == trytb.Type).FirstOrDefault().Value; - //g.mysql.Select().Where(a => g.mysql.Select().Where(b => b.Tag_id == a.Id && b.Song_id == 1).Any()); - var lmbdWhere = new StringBuilder(); - for (var a = 0; a < trytb.Primarys.Length; a++) { - var findtrytbPkCsName = trytb.Primarys[a].CsName.TrimStart('_'); - if (findtrytbPkCsName.StartsWith(trytb.Type.Name, StringComparison.CurrentCultureIgnoreCase)) findtrytbPkCsName = findtrytbPkCsName.Substring(trytb.Type.Name.Length).TrimStart('_'); - if (tbmid.ColumnsByCs.TryGetValue($"{midTypePropsTrytb.Name}{findtrytbPkCsName}", out var trycol) == false && //骆峰命名 - tbmid.ColumnsByCs.TryGetValue($"{midTypePropsTrytb.Name}_{findtrytbPkCsName}", out trycol) == false //下划线命名 - ) { + #region 在 tbref 命名空间下查找中间类 + if (midType == null) { + midType = tbref.Type.IsNested ? + tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{tbref.Type.DeclaringType.Name}+{trytb.CsName}{tbref.CsName}{midFlagStr}", false, true) : //SongTag + tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{trytb.CsName}{tbref.CsName}{midFlagStr}", false, true); + if (midType != null) { + var midTypeProps = midType.GetProperties(); + var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); + var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); + if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; + } + } + if (midType == null) { + midType = tbref.Type.IsNested ? + tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{tbref.Type.DeclaringType.Name}+{trytb.CsName}_{tbref.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true) : //Song_Tag + tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{trytb.CsName}_{tbref.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true); + if (midType != null) { + var midTypeProps = midType.GetProperties(); + var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); + var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); + if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; + } + } + if (midType == null) { + midType = tbref.Type.IsNested ? + tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{tbref.Type.DeclaringType.Name}+{tbref.CsName}{trytb.CsName}{midFlagStr}", false, true) : //TagSong + tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{tbref.CsName}{trytb.CsName}{midFlagStr}", false, true); + if (midType != null) { + var midTypeProps = midType.GetProperties(); + var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); + var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); + if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; + } + } + if (midType == null) { + midType = tbref.Type.IsNested ? + tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{tbref.Type.DeclaringType.Name}+{tbref.CsName}_{trytb.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true) : //Tag_Song + tbref.Type.Assembly.GetType($"{tbref.Type.Namespace}.{tbref.CsName}_{trytb.CsName}{(string.IsNullOrEmpty(midFlagStr) ? "" : "_")}{midFlagStr}", false, true); + if (midType != null) { + var midTypeProps = midType.GetProperties(); + var midTypePropsTrytb = midTypeProps.Where(a => a.PropertyType == trytb.Type).Count(); + var midTypePropsTbref = midTypeProps.Where(a => a.PropertyType == tbref.Type).Count(); + if (midTypePropsTrytb != 1 || midTypePropsTbref != 1) midType = null; + } + } + #endregion - } - if (trycol != null && trycol.CsType.NullableTypeOrThis() != trytb.Primarys[a].CsType) - throw new Exception($"【延时加载ManyToMany】导航属性 {trytbTypeName}.{vp.Item1.Name} 解析错误,{tbmid.CsName}.{trycol.CsName} 和 {trytb.CsName}.{trytb.Primarys[a].CsName} 类型不一致"); - if (trycol == null) - throw new Exception($"【延时加载ManyToMany】导航属性 {trytbTypeName}.{vp.Item1.Name} 在 {tbmid.CsName} 中没有找到对应的字段,如:{midTypePropsTrytb.Name}{findtrytbPkCsName}、{midTypePropsTrytb.Name}_{findtrytbPkCsName}"); + isManyToMany = midType != null; + } + if (isManyToMany) { + var tbmid = GetTableByEntity(midType, common); + var midTypePropsTrytb = tbmid.Properties.Where(a => a.Value.PropertyType == trytb.Type).FirstOrDefault().Value; + //g.mysql.Select().Where(a => g.mysql.Select().Where(b => b.Tag_id == a.Id && b.Song_id == 1).Any()); + var lmbdWhere = isLazy ? new StringBuilder() : null; + for (var a = 0; a < trytb.Primarys.Length; a++) { + var findtrytbPkCsName = trytb.Primarys[a].CsName.TrimStart('_'); + if (findtrytbPkCsName.StartsWith(trytb.Type.Name, StringComparison.CurrentCultureIgnoreCase)) findtrytbPkCsName = findtrytbPkCsName.Substring(trytb.Type.Name.Length).TrimStart('_'); + if (tbmid.ColumnsByCs.TryGetValue($"{midTypePropsTrytb.Name}{findtrytbPkCsName}", out var trycol) == false && //骆峰命名 + tbmid.ColumnsByCs.TryGetValue($"{midTypePropsTrytb.Name}_{findtrytbPkCsName}", out trycol) == false //下划线命名 + ) { + } + if (trycol != null && trycol.CsType.NullableTypeOrThis() != trytb.Primarys[a].CsType) { + nvref.Exception = new Exception($"【ManyToMany】导航属性 {trytbTypeName}.{pnv.Name} 解析错误,{tbmid.CsName}.{trycol.CsName} 和 {trytb.CsName}.{trytb.Primarys[a].CsName} 类型不一致"); + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + if (isLazy) throw nvref.Exception; + continue; + } + if (trycol == null) { + nvref.Exception = new Exception($"【ManyToMany】导航属性 {trytbTypeName}.{pnv.Name} 在 {tbmid.CsName} 中没有找到对应的字段,如:{midTypePropsTrytb.Name}{findtrytbPkCsName}、{midTypePropsTrytb.Name}_{findtrytbPkCsName}"); + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + if (isLazy) throw nvref.Exception; + continue; + } + + nvref.Columns.Add(trytb.Primarys[a]); + nvref.MiddleColumns.Add(trycol); + + if (isLazy) { if (a > 0) lmbdWhere.Append(" && "); lmbdWhere.Append("b.").Append(trycol.CsName).Append(" == this.").Append(trytb.Primarys[a].CsName); } + } - var midTypePropsTbref = tbmid.Properties.Where(a => a.Value.PropertyType == tbref.Type).FirstOrDefault().Value; - for (var a = 0; a < tbref.Primarys.Length; a++) { - var findtbrefPkCsName = tbref.Primarys[a].CsName.TrimStart('_'); - if (findtbrefPkCsName.StartsWith(tbref.Type.Name, StringComparison.CurrentCultureIgnoreCase)) findtbrefPkCsName = findtbrefPkCsName.Substring(tbref.Type.Name.Length).TrimStart('_'); - if (tbmid.ColumnsByCs.TryGetValue($"{midTypePropsTbref.Name}{findtbrefPkCsName}", out var trycol) == false && //骆峰命名 - tbmid.ColumnsByCs.TryGetValue($"{midTypePropsTbref.Name}_{findtbrefPkCsName}", out trycol) == false //下划线命名 - ) { + var midTypePropsTbref = tbmid.Properties.Where(a => a.Value.PropertyType == tbref.Type).FirstOrDefault().Value; + for (var a = 0; a < tbref.Primarys.Length; a++) { + var findtbrefPkCsName = tbref.Primarys[a].CsName.TrimStart('_'); + if (findtbrefPkCsName.StartsWith(tbref.Type.Name, StringComparison.CurrentCultureIgnoreCase)) findtbrefPkCsName = findtbrefPkCsName.Substring(tbref.Type.Name.Length).TrimStart('_'); + if (tbmid.ColumnsByCs.TryGetValue($"{midTypePropsTbref.Name}{findtbrefPkCsName}", out var trycol) == false && //骆峰命名 + tbmid.ColumnsByCs.TryGetValue($"{midTypePropsTbref.Name}_{findtbrefPkCsName}", out trycol) == false //下划线命名 + ) { - } - if (trycol != null && trycol.CsType.NullableTypeOrThis() != tbref.Primarys[a].CsType) - throw new Exception($"【延时加载ManyToMany】导航属性 {tbrefTypeName}.{vp.Item1.Name} 解析错误,{tbmid.CsName}.{trycol.CsName} 和 {tbref.CsName}.{tbref.Primarys[a].CsName} 类型不一致"); - if (trycol == null) - throw new Exception($"【延时加载ManyToMany】导航属性 {tbrefTypeName}.{vp.Item1.Name} 在 {tbmid.CsName} 中没有找到对应的字段,如:{midTypePropsTbref.Name}{findtbrefPkCsName}、{midTypePropsTbref.Name}_{findtbrefPkCsName}"); - - lmbdWhere.Append(" && b.").Append(trycol.CsName).Append(" == a.").Append(tbref.Primarys[a].CsName); + } + if (trycol != null && trycol.CsType.NullableTypeOrThis() != tbref.Primarys[a].CsType) { + nvref.Exception = new Exception($"【ManyToMany】导航属性 {tbrefTypeName}.{pnv.Name} 解析错误,{tbmid.CsName}.{trycol.CsName} 和 {tbref.CsName}.{tbref.Primarys[a].CsName} 类型不一致"); + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + if (isLazy) throw nvref.Exception; + continue; + } + if (trycol == null) { + nvref.Exception = new Exception($"【ManyToMany】导航属性 {tbrefTypeName}.{pnv.Name} 在 {tbmid.CsName} 中没有找到对应的字段,如:{midTypePropsTbref.Name}{findtbrefPkCsName}、{midTypePropsTbref.Name}_{findtbrefPkCsName}"); + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + if (isLazy) throw nvref.Exception; + continue; } - cscode.Append(" private bool __lazy__").Append(vp.Item1.Name).AppendLine(" = false;") - .Append(" public override ").Append(propTypeName).Append(" ").Append(vp.Item1.Name).AppendLine(" {"); + nvref.RefColumns.Add(tbref.Primarys[a]); + nvref.MiddleColumns.Add(trycol); + + if (isLazy) lmbdWhere.Append(" && b.").Append(trycol.CsName).Append(" == a.").Append(tbref.Primarys[a].CsName); + } + if (nvref.Columns.Count > 0 && nvref.RefColumns.Count > 0) { + nvref.RefMiddleEntityType = tbmid.Type; + nvref.RefEntityType = tbref.Type; + nvref.RefType = TableRefType.ManyToMany; + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + } + + if (isLazy) { + cscode.Append(" private bool __lazy__").Append(pnv.Name).AppendLine(" = false;") + .Append(" public override ").Append(propTypeName).Append(" ").Append(pnv.Name).AppendLine(" {"); if (vp.Item2) { //get 重写 cscode.Append(" get {\r\n") - .Append(" if (base.").Append(vp.Item1.Name).Append(" == null && __lazy__").Append(vp.Item1.Name).AppendLine(" == false) {") - .Append(" base.").Append(vp.Item1.Name).Append(" = __fsql_orm__.Select<").Append(propElementType.IsNested ? $"{propElementType.DeclaringType.Namespace}.{propElementType.DeclaringType.Name}.{propElementType.Name}" : $"{propElementType.Namespace}.{propElementType.Name}") + .Append(" if (base.").Append(pnv.Name).Append(" == null && __lazy__").Append(pnv.Name).AppendLine(" == false) {") + .Append(" base.").Append(pnv.Name).Append(" = __fsql_orm__.Select<").Append(propElementType.IsNested ? $"{propElementType.DeclaringType.Namespace}.{propElementType.DeclaringType.Name}.{propElementType.Name}" : $"{propElementType.Namespace}.{propElementType.Name}") .Append(">().Where(a => __fsql_orm__.Select<").Append(tbmid.Type.IsNested ? $"{tbmid.Type.DeclaringType.Namespace}.{tbmid.Type.DeclaringType.Name}.{tbmid.Type.Name}" : $"{tbmid.Type.Namespace}.{tbmid.Type.Name}") .Append(">().Where(b => ").Append(lmbdWhere.ToString()).AppendLine(").Any()).ToList();"); - cscode.Append(" __lazy__").Append(vp.Item1.Name).AppendLine(" = true;") + cscode.Append(" __lazy__").Append(pnv.Name).AppendLine(" = true;") .Append(" }\r\n") - .Append(" return base.").Append(vp.Item1.Name).AppendLine(";") + .Append(" return base.").Append(pnv.Name).AppendLine(";") .Append(" }\r\n"); } if (vp.Item3) { //set 重写 - cscode.Append(" set => base.").Append(vp.Item1.Name).AppendLine(" = value;"); + cscode.Append(" set => base.").Append(pnv.Name).AppendLine(" = value;"); } cscode.AppendLine(" }"); + } + } else { //One To Many + var refcols = tbref.Properties.Where(z => z.Value.PropertyType == trytb.Type); + var refprop = refcols.Count() == 1 ? refcols.First().Value : null; + var lmbdWhere = isLazy ? new StringBuilder() : null; + for (var a = 0; a < trytb.Primarys.Length; a++) { + var findtrytbPkCsName = trytb.Primarys[a].CsName.TrimStart('_'); + if (findtrytbPkCsName.StartsWith(trytb.Type.Name, StringComparison.CurrentCultureIgnoreCase)) findtrytbPkCsName = findtrytbPkCsName.Substring(trytb.Type.Name.Length).TrimStart('_'); + var findtrytb = pnv.Name; + if (findtrytb.EndsWith(tbref.CsName + "s")) findtrytb = findtrytb.Substring(0, findtrytb.Length - tbref.CsName.Length - 1); + findtrytb += trytb.CsName; + if (tbref.ColumnsByCs.TryGetValue($"{findtrytb}{findtrytbPkCsName}", out var trycol) == false && //骆峰命名 + tbref.ColumnsByCs.TryGetValue($"{findtrytb}_{findtrytbPkCsName}", out trycol) == false //下划线命名 + ) { + if (refprop != null && + tbref.ColumnsByCs.TryGetValue($"{refprop.Name}{findtrytbPkCsName}", out trycol) == false && //骆峰命名 + tbref.ColumnsByCs.TryGetValue($"{refprop.Name}_{findtrytbPkCsName}", out trycol) == false) //下划线命名 + { - } else { //One To Many - var refcols = tbref.Properties.Where(z => z.Value.PropertyType == trytb.Type); - var refprop = refcols.Count() == 1 ? refcols.First().Value : null; - var lmbdWhere = new StringBuilder(); - for (var a = 0; a < trytb.Primarys.Length; a++) { - var findtrytbPkCsName = trytb.Primarys[a].CsName.TrimStart('_'); - if (findtrytbPkCsName.StartsWith(trytb.Type.Name, StringComparison.CurrentCultureIgnoreCase)) findtrytbPkCsName = findtrytbPkCsName.Substring(trytb.Type.Name.Length).TrimStart('_'); - var findtrytb = vp.Item1.Name; - if (findtrytb.EndsWith(tbref.CsName + "s")) findtrytb = findtrytb.Substring(0, findtrytb.Length - tbref.CsName.Length - 1); - findtrytb += trytb.CsName; - if (tbref.ColumnsByCs.TryGetValue($"{findtrytb}{findtrytbPkCsName}", out var trycol) == false && //骆峰命名 - tbref.ColumnsByCs.TryGetValue($"{findtrytb}_{findtrytbPkCsName}", out trycol) == false //下划线命名 - ) { - if (refprop != null && - tbref.ColumnsByCs.TryGetValue($"{refprop.Name}{findtrytbPkCsName}", out trycol) == false && //骆峰命名 - tbref.ColumnsByCs.TryGetValue($"{refprop.Name}_{findtrytbPkCsName}", out trycol) == false) //下划线命名 - { - - } - if (trycol != null && trycol.CsType.NullableTypeOrThis() != trytb.Primarys[a].CsType) - throw new Exception($"【延时加载OneToMany】导航属性 {trytbTypeName}.{vp.Item1.Name} 解析错误,{trytb.CsName}.{trytb.Primarys[a].CsName} 和 {tbref.CsName}.{trycol.CsName} 类型不一致"); - if (trycol == null) - throw new Exception($"【延时加载OneToMany】导航属性 {trytbTypeName}.{vp.Item1.Name} 在 {tbref.CsName} 中没有找到对应的字段,如:{findtrytb}{findtrytbPkCsName}、{findtrytb}_{findtrytbPkCsName}" + (refprop == null ? "" : $"、{refprop.Name}{findtrytbPkCsName}、{refprop.Name}_{findtrytbPkCsName}")); } + if (trycol != null && trycol.CsType.NullableTypeOrThis() != trytb.Primarys[a].CsType) { + nvref.Exception = new Exception($"【OneToMany】导航属性 {trytbTypeName}.{pnv.Name} 解析错误,{trytb.CsName}.{trytb.Primarys[a].CsName} 和 {tbref.CsName}.{trycol.CsName} 类型不一致"); + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + if (isLazy) throw nvref.Exception; + continue; + } + if (trycol == null) { + nvref.Exception = new Exception($"【OneToMany】导航属性 {trytbTypeName}.{pnv.Name} 在 {tbref.CsName} 中没有找到对应的字段,如:{findtrytb}{findtrytbPkCsName}、{findtrytb}_{findtrytbPkCsName}" + (refprop == null ? "" : $"、{refprop.Name}{findtrytbPkCsName}、{refprop.Name}_{findtrytbPkCsName}")); + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + if (isLazy) throw nvref.Exception; + continue; + } + } + + nvref.Columns.Add(trytb.Primarys[a]); + nvref.RefColumns.Add(trycol); + + if (isLazy) { if (a > 0) lmbdWhere.Append(" && "); lmbdWhere.Append("a.").Append(trycol.CsName).Append(" == this.").Append(trytb.Primarys[a].CsName); @@ -381,103 +446,132 @@ namespace FreeSql.Internal { } } } + } + if (nvref.Columns.Count > 0 && nvref.RefColumns.Count > 0) { + nvref.RefEntityType = tbref.Type; + nvref.RefType = TableRefType.OneToMany; + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + } - cscode.Append(" private bool __lazy__").Append(vp.Item1.Name).AppendLine(" = false;") - .Append(" public override ").Append(propTypeName).Append(" ").Append(vp.Item1.Name).AppendLine(" {"); + if (isLazy) { + cscode.Append(" private bool __lazy__").Append(pnv.Name).AppendLine(" = false;") + .Append(" public override ").Append(propTypeName).Append(" ").Append(pnv.Name).AppendLine(" {"); if (vp.Item2) { //get 重写 cscode.Append(" get {\r\n") - .Append(" if (base.").Append(vp.Item1.Name).Append(" == null && __lazy__").Append(vp.Item1.Name).AppendLine(" == false) {") - .Append(" base.").Append(vp.Item1.Name).Append(" = __fsql_orm__.Select<").Append(propElementType.IsNested ? $"{propElementType.DeclaringType.Namespace}.{propElementType.DeclaringType.Name}.{propElementType.Name}" : $"{propElementType.Namespace}.{propElementType.Name}").Append(">().Where(a => ").Append(lmbdWhere.ToString()).AppendLine(").ToList();"); + .Append(" if (base.").Append(pnv.Name).Append(" == null && __lazy__").Append(pnv.Name).AppendLine(" == false) {") + .Append(" base.").Append(pnv.Name).Append(" = __fsql_orm__.Select<").Append(propElementType.IsNested ? $"{propElementType.DeclaringType.Namespace}.{propElementType.DeclaringType.Name}.{propElementType.Name}" : $"{propElementType.Namespace}.{propElementType.Name}").Append(">().Where(a => ").Append(lmbdWhere.ToString()).AppendLine(").ToList();"); if (refprop != null) { - cscode.Append(" foreach (var loc1 in base.").Append(vp.Item1.Name).AppendLine(")") + cscode.Append(" foreach (var loc1 in base.").Append(pnv.Name).AppendLine(")") .Append(" loc1.").Append(refprop.Name).AppendLine(" = this;"); } - cscode.Append(" __lazy__").Append(vp.Item1.Name).AppendLine(" = true;") + cscode.Append(" __lazy__").Append(pnv.Name).AppendLine(" = true;") .Append(" }\r\n") - .Append(" return base.").Append(vp.Item1.Name).AppendLine(";") + .Append(" return base.").Append(pnv.Name).AppendLine(";") .Append(" }\r\n"); } if (vp.Item3) { //set 重写 - cscode.Append(" set => base.").Append(vp.Item1.Name).AppendLine(" = value;"); + cscode.Append(" set => base.").Append(pnv.Name).AppendLine(" = value;"); } cscode.AppendLine(" }"); } - - } else { //一对一、多对一 - var tbref = vp.Item1.PropertyType == trytb.Type ? trytb : GetTableByEntity(vp.Item1.PropertyType, common); //可能是父子关系 - if (tbref == null) continue; - if (tbref.Primarys.Any() == false) { - //continue; - throw new Exception($"【延时加载】导航属性 {trytbTypeName}.{vp.Item1.Name} 解析错误,实体类型 {propTypeName} 缺少主键标识,[Column(IsPrimary = true)]"); - } - var isOnoToOne = vp.Item1.PropertyType != trytb.Type && - tbref.Properties.Where(z => z.Value.PropertyType == trytb.Type).Any() && - tbref.Primarys.Length == trytb.Primarys.Length && - string.Join(",", tbref.Primarys.Select(a => a.CsType.FullName)) == string.Join(",", trytb.Primarys.Select(a => a.CsType.FullName)); - var lmbdWhere = new StringBuilder(); - for (var a = 0; a < tbref.Primarys.Length; a++) { - var findtbrefPkCsName = tbref.Primarys[a].CsName.TrimStart('_'); - if (findtbrefPkCsName.StartsWith(tbref.Type.Name, StringComparison.CurrentCultureIgnoreCase)) findtbrefPkCsName = findtbrefPkCsName.Substring(tbref.Type.Name.Length).TrimStart('_'); - if (trytb.ColumnsByCs.TryGetValue($"{vp.Item1.Name}{findtbrefPkCsName}", out var trycol) == false && //骆峰命名 - trytb.ColumnsByCs.TryGetValue($"{vp.Item1.Name}_{findtbrefPkCsName}", out trycol) == false //下划线命名 - ) { - //一对一,主键与主键查找 - if (isOnoToOne) { - var trytbpks = trytb.Primarys.Where(z => z.CsType == tbref.Primarys[a].CsType); //一对一,按类型 + } + } else { //一对一、多对一 + var tbref = pnv.PropertyType == trytb.Type ? trytb : GetTableByEntity(pnv.PropertyType, common); //可能是父子关系 + if (tbref == null) continue; + if (tbref.Primarys.Any() == false) { + nvref.Exception = new Exception($"导航属性 {trytbTypeName}.{pnv.Name} 解析错误,实体类型 {propTypeName} 缺少主键标识,[Column(IsPrimary = true)]"); + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + if (isLazy) throw nvref.Exception; + continue; + } + var isOnoToOne = pnv.PropertyType != trytb.Type && + tbref.Properties.Where(z => z.Value.PropertyType == trytb.Type).Any() && + tbref.Primarys.Length == trytb.Primarys.Length && + string.Join(",", tbref.Primarys.Select(a => a.CsType.FullName).OrderBy(a => a)) == string.Join(",", trytb.Primarys.Select(a => a.CsType.FullName).OrderBy(a => a)); + var lmbdWhere = new StringBuilder(); + for (var a = 0; a < tbref.Primarys.Length; a++) { + var findtbrefPkCsName = tbref.Primarys[a].CsName.TrimStart('_'); + if (findtbrefPkCsName.StartsWith(tbref.Type.Name, StringComparison.CurrentCultureIgnoreCase)) findtbrefPkCsName = findtbrefPkCsName.Substring(tbref.Type.Name.Length).TrimStart('_'); + if (trytb.ColumnsByCs.TryGetValue($"{pnv.Name}{findtbrefPkCsName}", out var trycol) == false && //骆峰命名 + trytb.ColumnsByCs.TryGetValue($"{pnv.Name}_{findtbrefPkCsName}", out trycol) == false //下划线命名 + ) { + //一对一,主键与主键查找 + if (isOnoToOne) { + var trytbpks = trytb.Primarys.Where(z => z.CsType == tbref.Primarys[a].CsType); //一对一,按类型 + if (trytbpks.Count() == 1) trycol = trytbpks.First(); + else { + trytbpks = trytb.Primarys.Where(z => string.Compare(z.CsName, tbref.Primarys[a].CsName, true) == 0); //一对一,按主键名相同 if (trytbpks.Count() == 1) trycol = trytbpks.First(); else { - trytbpks = trytb.Primarys.Where(z => string.Compare(z.CsName, tbref.Primarys[a].CsName, true) == 0); //一对一,按主键名相同 + trytbpks = trytb.Primarys.Where(z => string.Compare(z.CsName, $"{tbref.CsName}{tbref.Primarys[a].CsName}", true) == 0); //一对一,主键名 = 表+主键名 if (trytbpks.Count() == 1) trycol = trytbpks.First(); else { - trytbpks = trytb.Primarys.Where(z => string.Compare(z.CsName, $"{tbref.CsName}{tbref.Primarys[a].CsName}", true) == 0); //一对一,主键名 = 表+主键名 + trytbpks = trytb.Primarys.Where(z => string.Compare(z.CsName, $"{tbref.CsName}_{tbref.Primarys[a].CsName}", true) == 0); //一对一,主键名 = 表+_主键名 if (trytbpks.Count() == 1) trycol = trytbpks.First(); - else { - trytbpks = trytb.Primarys.Where(z => string.Compare(z.CsName, $"{tbref.CsName}_{tbref.Primarys[a].CsName}", true) == 0); //一对一,主键名 = 表+_主键名 - if (trytbpks.Count() == 1) trycol = trytbpks.First(); - } } } } - if (trycol != null && trycol.CsType.NullableTypeOrThis() != tbref.Primarys[a].CsType) - throw new Exception($"【延时加载】导航属性 {trytbTypeName}.{vp.Item1.Name} 解析错误,{trytb.CsName}.{trycol.CsName} 和 {tbref.CsName}.{tbref.Primarys[a].CsName} 类型不一致"); - if (trycol == null) - throw new Exception($"【延时加载】导航属性 {trytbTypeName}.{vp.Item1.Name} 没有找到对应的字段,如:{vp.Item1.Name}{findtbrefPkCsName}、{vp.Item1.Name}_{findtbrefPkCsName}"); } + if (trycol != null && trycol.CsType.NullableTypeOrThis() != tbref.Primarys[a].CsType) { + nvref.Exception = new Exception($"导航属性 {trytbTypeName}.{pnv.Name} 解析错误,{trytb.CsName}.{trycol.CsName} 和 {tbref.CsName}.{tbref.Primarys[a].CsName} 类型不一致"); + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + if (isLazy) throw nvref.Exception; + continue; + } + if (trycol == null) { + nvref.Exception = new Exception($"导航属性 {trytbTypeName}.{pnv.Name} 没有找到对应的字段,如:{pnv.Name}{findtbrefPkCsName}、{pnv.Name}_{findtbrefPkCsName}"); + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + if (isLazy) throw nvref.Exception; + continue; + } + } + + nvref.Columns.Add(trycol); + nvref.RefColumns.Add(tbref.Primarys[a]); + + if (isLazy) { if (a > 0) lmbdWhere.Append(" && "); lmbdWhere.Append("a.").Append(tbref.Primarys[a].CsName).Append(" == this.").Append(trycol.CsName); } + } + if (nvref.Columns.Count > 0 && nvref.RefColumns.Count > 0) { + nvref.RefEntityType = tbref.Type; + nvref.RefType = isOnoToOne ? TableRefType.OneToOne : TableRefType.OneToMany; + trytb.AddOrUpdateTableRef(pnv.Name, nvref); + } - cscode.Append(" private bool __lazy__").Append(vp.Item1.Name).AppendLine(" = false;") - .Append(" public override ").Append(propTypeName).Append(" ").Append(vp.Item1.Name).AppendLine(" {"); + if (isLazy) { + cscode.Append(" private bool __lazy__").Append(pnv.Name).AppendLine(" = false;") + .Append(" public override ").Append(propTypeName).Append(" ").Append(pnv.Name).AppendLine(" {"); if (vp.Item2) { //get 重写 cscode.Append(" get {\r\n") - .Append(" if (base.").Append(vp.Item1.Name).Append(" == null && __lazy__").Append(vp.Item1.Name).AppendLine(" == false) {") - .Append(" base.").Append(vp.Item1.Name).Append(" = __fsql_orm__.Select<").Append(propTypeName).Append(">().Where(a => ").Append(lmbdWhere.ToString()).AppendLine(").ToOne();") - .Append(" __lazy__").Append(vp.Item1.Name).AppendLine(" = true;") + .Append(" if (base.").Append(pnv.Name).Append(" == null && __lazy__").Append(pnv.Name).AppendLine(" == false) {") + .Append(" base.").Append(pnv.Name).Append(" = __fsql_orm__.Select<").Append(propTypeName).Append(">().Where(a => ").Append(lmbdWhere.ToString()).AppendLine(").ToOne();") + .Append(" __lazy__").Append(pnv.Name).AppendLine(" = true;") .Append(" }\r\n") - .Append(" return base.").Append(vp.Item1.Name).AppendLine(";") + .Append(" return base.").Append(pnv.Name).AppendLine(";") .Append(" }\r\n"); } if (vp.Item3) { //set 重写 - cscode.Append(" set => base.").Append(vp.Item1.Name).AppendLine(" = value;"); + cscode.Append(" set => base.").Append(pnv.Name).AppendLine(" = value;"); } cscode.AppendLine(" }"); + } + } - } - ++overrieds; - } - if (overrieds > 0) { - cscode.AppendLine("}"); - Assembly assembly = null; - try { - assembly = Generator.TemplateEngin._compiler.Value.CompileCode(cscode.ToString()); - } catch (Exception ex) { - throw new Exception($"【延时加载】{trytbTypeName} 编译错误:{ex.Message}\r\n\r\n{cscode}"); - } - var type = assembly.DefinedTypes.Where(a => a.FullName.EndsWith(trytbTypeLazyName)).FirstOrDefault(); - trytb.TypeLazy = type; - trytb.TypeLazySetOrm = type.GetProperty("__fsql_orm__", BindingFlags.Instance | BindingFlags.NonPublic).GetSetMethod(true); + if (isLazy)++overrieds; + } + if (overrieds > 0) { + cscode.AppendLine("}"); + Assembly assembly = null; + try { + assembly = Generator.TemplateEngin._compiler.Value.CompileCode(cscode.ToString()); + } catch (Exception ex) { + throw new Exception($"【延时加载】{trytbTypeName} 编译错误:{ex.Message}\r\n\r\n{cscode}"); } + var type = assembly.DefinedTypes.Where(a => a.FullName.EndsWith(trytbTypeLazyName)).FirstOrDefault(); + trytb.TypeLazy = type; + trytb.TypeLazySetOrm = type.GetProperty("__fsql_orm__", BindingFlags.Instance | BindingFlags.NonPublic).GetSetMethod(true); } #endregion diff --git a/FreeSql/MySql/Curd/MySqlSelect.cs b/FreeSql/MySql/Curd/MySqlSelect.cs index 16954878..8950a163 100644 --- a/FreeSql/MySql/Curd/MySqlSelect.cs +++ b/FreeSql/MySql/Curd/MySqlSelect.cs @@ -15,6 +15,7 @@ namespace FreeSql.MySql.Curd { _orm.CodeFirst.SyncStructure(_tables.Select(a => a.Table.Type).ToArray()); var sb = new StringBuilder(); + var sbnav = new StringBuilder(); sb.Append(_select).Append(field).Append(" \r\nFROM "); var tbsjoin = _tables.Where(a => a.Type != SelectTableInfoType.From).ToArray(); var tbsfrom = _tables.Where(a => a.Type == SelectTableInfoType.From).ToArray(); @@ -23,9 +24,14 @@ namespace FreeSql.MySql.Curd { if (tbsjoin.Length > 0) { //如果存在 join 查询,则处理 from t1, t2 改为 from t1 inner join t2 on 1 = 1 for (var b = 1; b < tbsfrom.Length; b++) { - sb.Append(" \r\nLEFT JOIN ").Append(_commonUtils.QuoteSqlName(tableRuleInvoke(tbsfrom[b].Table.Type, tbsfrom[b].Table.DbName))).Append(" ").Append(tbsfrom[b].Alias).Append(" ON 1 = 1"); + sb.Append(" \r\nLEFT JOIN ").Append(_commonUtils.QuoteSqlName(tableRuleInvoke(tbsfrom[b].Table.Type, tbsfrom[b].Table.DbName))).Append(" ").Append(tbsfrom[b].Alias); + if (string.IsNullOrEmpty(tbsfrom[b].NavigateCondition) && string.IsNullOrEmpty(tbsfrom[b].On)) sb.Append(" ON 1 = 1"); + else sb.Append(" ON ").Append(tbsfrom[b].NavigateCondition ?? tbsfrom[b].On); } break; + } else { + if (!string.IsNullOrEmpty(tbsfrom[a].NavigateCondition)) sbnav.Append(" AND (").Append(tbsfrom[a].NavigateCondition).Append(")"); + if (!string.IsNullOrEmpty(tbsfrom[a].On)) sbnav.Append(" AND (").Append(tbsfrom[a].On).Append(")"); } if (a < tbsfrom.Length - 1) sb.Append(", "); } @@ -43,20 +49,19 @@ namespace FreeSql.MySql.Curd { break; } sb.Append(_commonUtils.QuoteSqlName(tableRuleInvoke(tb.Table.Type, tb.Table.DbName))).Append(" ").Append(tb.Alias).Append(" ON ").Append(tb.On); + if (!string.IsNullOrEmpty(tb.NavigateCondition)) sbnav.Append(" AND (").Append(tb.NavigateCondition).Append(")"); + if (!string.IsNullOrEmpty(tb.On)) sbnav.Append(" AND (").Append(tb.On).Append(")"); } if (_join.Length > 0) sb.Append(_join); - var sbqf = new StringBuilder(); + sbnav.Append(_where); foreach (var tb in _tables) { if (tb.Type == SelectTableInfoType.Parent) continue; if (string.IsNullOrEmpty(tb.Table.SelectFilter) == false) - sbqf.Append(" AND (").Append(tb.Table.SelectFilter.Replace("a.", $"{tb.Alias}.")).Append(")"); + sbnav.Append(" AND (").Append(tb.Table.SelectFilter.Replace("a.", $"{tb.Alias}.")).Append(")"); } - if (_where.Length > 0) { - sb.Append(" \r\nWHERE ").Append(_where.ToString().Substring(5)); - if (sbqf.Length > 0) sb.Append(sbqf.ToString()); - } else { - if (sbqf.Length > 0) sb.Append(" \r\nWHERE ").Append(sbqf.Remove(0, 5)); + if (sbnav.Length > 0) { + sb.Append(" \r\nWHERE ").Append(sbnav.Remove(0, 5)); } if (string.IsNullOrEmpty(_groupby) == false) { sb.Append(_groupby); @@ -67,18 +72,19 @@ namespace FreeSql.MySql.Curd { if (_skip > 0 || _limit > 0) sb.Append(" \r\nlimit ").Append(Math.Max(0, _skip)).Append(",").Append(_limit > 0 ? _limit : -1); + sbnav.Clear(); return sb.ToString(); } public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { } - public override ISelect From(Expression, T2, T3, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret); return ret; } + public override ISelect From(Expression, T2, T3, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect(_orm, _commonUtils, _commonExpression, null); MySqlSelect.CopyData(this, ret, exp?.Parameters); return ret; } public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm); } class MySqlSelect : FreeSql.Internal.CommonProvider.Select3Provider where T1 : class where T2 : class where T3 : class { diff --git a/FreeSql/Oracle/Curd/OracleSelect.cs b/FreeSql/Oracle/Curd/OracleSelect.cs index 31592e0e..9f26bc38 100644 --- a/FreeSql/Oracle/Curd/OracleSelect.cs +++ b/FreeSql/Oracle/Curd/OracleSelect.cs @@ -81,14 +81,14 @@ namespace FreeSql.Oracle.Curd { } public OracleSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { } - public override ISelect From(Expression, T2, T3, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret); return ret; } + public override ISelect From(Expression, T2, T3, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect(_orm, _commonUtils, _commonExpression, null); OracleSelect.CopyData(this, ret, exp?.Parameters); return ret; } public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm); } class OracleSelect : FreeSql.Internal.CommonProvider.Select3Provider where T1 : class where T2 : class where T3 : class { diff --git a/FreeSql/PostgreSQL/Curd/PostgreSQLSelect.cs b/FreeSql/PostgreSQL/Curd/PostgreSQLSelect.cs index 559c47eb..0648c8e0 100644 --- a/FreeSql/PostgreSQL/Curd/PostgreSQLSelect.cs +++ b/FreeSql/PostgreSQL/Curd/PostgreSQLSelect.cs @@ -72,14 +72,14 @@ namespace FreeSql.PostgreSQL.Curd { } public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { } - public override ISelect From(Expression, T2, T3, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret); return ret; } + public override ISelect From(Expression, T2, T3, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect.CopyData(this, ret, exp?.Parameters); return ret; } public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm); } //class PostgreSQLSelect : FreeSql.Internal.CommonProvider.Select2Provider where T1 : class where T2 : class { diff --git a/FreeSql/SqlServer/Curd/SqlServerSelect.cs b/FreeSql/SqlServer/Curd/SqlServerSelect.cs index db475344..e37e0824 100644 --- a/FreeSql/SqlServer/Curd/SqlServerSelect.cs +++ b/FreeSql/SqlServer/Curd/SqlServerSelect.cs @@ -161,14 +161,14 @@ namespace FreeSql.SqlServer.Curd { #endregion public SqlServerSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { } - public override ISelect From(Expression, T2, T3, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret); return ret; } + public override ISelect From(Expression, T2, T3, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect(_orm, _commonUtils, _commonExpression, null); SqlServerSelect.CopyData(this, ret, exp?.Parameters); return ret; } public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm); } //class SqlServerSelect : FreeSql.Internal.CommonProvider.Select2Provider where T1 : class where T2 : class { diff --git a/FreeSql/Sqlite/Curd/SqliteSelect.cs b/FreeSql/Sqlite/Curd/SqliteSelect.cs index 693bb287..93a49cda 100644 --- a/FreeSql/Sqlite/Curd/SqliteSelect.cs +++ b/FreeSql/Sqlite/Curd/SqliteSelect.cs @@ -70,14 +70,14 @@ namespace FreeSql.Sqlite.Curd { } public SqliteSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { } - public override ISelect From(Expression, T2, T3, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret); return ret; } - public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret); return ret; } + public override ISelect From(Expression, T2, T3, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret, exp?.Parameters); return ret; } + public override ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect(_orm, _commonUtils, _commonExpression, null); SqliteSelect.CopyData(this, ret, exp?.Parameters); return ret; } public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm); } class SqliteSelect : FreeSql.Internal.CommonProvider.Select3Provider where T1 : class where T2 : class where T3 : class {