mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	增加 int.Parse Guid.Parse 系列转换、Guid.NewGuid、new Random.NextDouble 等表达式函数解析
This commit is contained in:
		@@ -1,25 +1,31 @@
 | 
				
			|||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Diagnostics;
 | 
				
			||||||
using System.Text;
 | 
					using System.Text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace FreeSql.Tests.DataContext.SqlServer
 | 
					namespace FreeSql.Tests.DataContext.SqlServer {
 | 
				
			||||||
{
 | 
						public class SqlServerFixture : IDisposable {
 | 
				
			||||||
	public class SqlServerFixture : IDisposable
 | 
							public SqlServerFixture() {
 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		public SqlServerFixture()
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			sqlServerLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
 | 
								sqlServerLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
 | 
				
			||||||
			  .UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=10")
 | 
								  .UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=10")
 | 
				
			||||||
			  //.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=(localdb)\\mssqllocaldb;Integrated Security=True;Initial Catalog=cms;Pooling=true;Max Pool Size=10")
 | 
								  //.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=(localdb)\\mssqllocaldb;Integrated Security=True;Initial Catalog=cms;Pooling=true;Max Pool Size=10")
 | 
				
			||||||
			  .UseAutoSyncStructure(true)
 | 
								  .UseAutoSyncStructure(true)
 | 
				
			||||||
			  .UseLazyLoading(true)
 | 
								  .UseLazyLoading(true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								  .UseMonitorCommand(
 | 
				
			||||||
 | 
									cmd => {
 | 
				
			||||||
 | 
										Trace.WriteLine(cmd.CommandText);
 | 
				
			||||||
 | 
									}, //监听SQL命令对象,在执行前
 | 
				
			||||||
 | 
									(cmd, traceLog) => {
 | 
				
			||||||
 | 
										Console.WriteLine(traceLog);
 | 
				
			||||||
 | 
									}) //监听SQL命令对象,在执行后
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			  .Build());
 | 
								  .Build());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// ... initialize data in the test database ...
 | 
								// ... initialize data in the test database ...
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public void Dispose()
 | 
							public void Dispose() {
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			// ... clean up test data from the database ...
 | 
								// ... clean up test data from the database ...
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -284,8 +284,7 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
			//<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
								//<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
				
			||||||
			var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid);
 | 
								var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid);
 | 
				
			||||||
			var sql = query.ToSql().Replace("\r\n", "");
 | 
								var sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			//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`", 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.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx");
 | 
								query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx");
 | 
				
			||||||
@@ -295,7 +294,6 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && 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", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			//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);
 | 
								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.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -312,7 +310,6 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
 | 
								query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			//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);
 | 
								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.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -325,11 +322,10 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
			query.ToList();
 | 
								query.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			query = select
 | 
								query = select
 | 
				
			||||||
				.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid)
 | 
									.LeftJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid)
 | 
				
			||||||
				.LeftJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId);
 | 
									.LeftJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId);
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			//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`, 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` c ON c.`Id` = a__Type.`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();
 | 
								query.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
 | 
								//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
 | 
				
			||||||
@@ -366,7 +362,6 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid && 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", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			//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);
 | 
								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.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -383,7 +378,6 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			query = select.InnerJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
 | 
								query = select.InnerJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			//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);
 | 
								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.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -396,11 +390,10 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
			query.ToList();
 | 
								query.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			query = select
 | 
								query = select
 | 
				
			||||||
				.InnerJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid)
 | 
									.InnerJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid)
 | 
				
			||||||
				.InnerJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId);
 | 
									.InnerJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId);
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			//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`, 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` c ON c.`Id` = a__Type.`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();
 | 
								query.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
 | 
								//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
 | 
				
			||||||
@@ -438,7 +431,7 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			query = select.RightJoin(a => a.Type.Guid == a.TypeGuid && 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", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								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' LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId` WHERE (a__Type__Parent.`Id` = 10)", sql);
 | 
				
			||||||
			query.ToList();
 | 
								query.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
								//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
				
			||||||
@@ -454,7 +447,7 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			query = select.RightJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
 | 
								query = select.RightJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								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` 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.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
								//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
				
			||||||
@@ -466,10 +459,10 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
			query.ToList();
 | 
								query.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			query = select
 | 
								query = select
 | 
				
			||||||
				.RightJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid)
 | 
									.RightJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid)
 | 
				
			||||||
				.RightJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId);
 | 
									.RightJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId);
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								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` c ON c.`Id` = a__Type.`ParentId`", sql);
 | 
				
			||||||
			query.ToList();
 | 
								query.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
 | 
								//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
 | 
				
			||||||
@@ -512,17 +505,17 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			query = select.Where(a => a.Type.Name == "typeTitle");
 | 
								query = select.Where(a => a.Type.Name == "typeTitle");
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								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.`Name` = 'typeTitle')", sql);
 | 
				
			||||||
			query.ToList();
 | 
								query.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid);
 | 
								query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid);
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								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.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TypeGuid`)", sql);
 | 
				
			||||||
			query.ToList();
 | 
								query.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			query = select.Where(a => a.Type.Parent.Name == "tparent");
 | 
								query = select.Where(a => a.Type.Parent.Name == "tparent");
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								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` WHERE (a__Type__Parent.`Name` = 'tparent')", sql);
 | 
				
			||||||
			query.ToList();
 | 
								query.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><F2B5A5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
								//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><F2B5A5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
				
			||||||
@@ -546,7 +539,7 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
				.Where(a => a.Id == 10 && c.Name == "xxx")
 | 
									.Where(a => a.Id == 10 && c.Name == "xxx")
 | 
				
			||||||
				.Where(a => b.ParentId == 20));
 | 
									.Where(a => b.ParentId == 20));
 | 
				
			||||||
			sql = query2.ToSql().Replace("\r\n", "");
 | 
								sql = query2.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` b, `TestTypeParentInfo` c WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20)", sql);
 | 
				
			||||||
			query2.ToList();
 | 
								query2.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
 | 
								//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
 | 
				
			||||||
@@ -575,17 +568,17 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			query = select.WhereIf(true, a => a.Type.Name == "typeTitle");
 | 
								query = select.WhereIf(true, a => a.Type.Name == "typeTitle");
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								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.`Name` = 'typeTitle')", sql);
 | 
				
			||||||
			query.ToList();
 | 
								query.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid);
 | 
								query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid);
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								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.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TypeGuid`)", sql);
 | 
				
			||||||
			query.ToList();
 | 
								query.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			query = select.WhereIf(true, a => a.Type.Parent.Name == "tparent");
 | 
								query = select.WhereIf(true, a => a.Type.Parent.Name == "tparent");
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								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` WHERE (a__Type__Parent.`Name` = 'tparent')", sql);
 | 
				
			||||||
			query.ToList();
 | 
								query.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> From <20><>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
								//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> From <20><>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
				
			||||||
@@ -593,7 +586,7 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
				.WhereIf(true, a => a.Id == 10 && c.Name == "xxx")
 | 
									.WhereIf(true, a => a.Id == 10 && c.Name == "xxx")
 | 
				
			||||||
				.WhereIf(true, a => b.ParentId == 20));
 | 
									.WhereIf(true, a => b.ParentId == 20));
 | 
				
			||||||
			sql = query2.ToSql().Replace("\r\n", "");
 | 
								sql = query2.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` b, `TestTypeParentInfo` c WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20)", sql);
 | 
				
			||||||
			query2.ToList();
 | 
								query2.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
 | 
								//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
 | 
				
			||||||
@@ -640,7 +633,7 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
				.WhereIf(false, a => a.Id == 10 && c.Name == "xxx")
 | 
									.WhereIf(false, a => a.Id == 10 && c.Name == "xxx")
 | 
				
			||||||
				.WhereIf(false, a => b.ParentId == 20));
 | 
									.WhereIf(false, a => b.ParentId == 20));
 | 
				
			||||||
			sql = query2.ToSql().Replace("\r\n", "");
 | 
								sql = query2.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, 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, `TestTypeInfo` b, `TestTypeParentInfo` c", sql);
 | 
				
			||||||
			query2.ToList();
 | 
								query2.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
 | 
								//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
 | 
				
			||||||
@@ -732,7 +725,7 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && 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", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								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' LEFT JOIN `TestTypeParentInfoAsTable` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId` WHERE (a__Type__Parent.`Id` = 10)", sql);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
								//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
				
			||||||
			query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid).AsTable(tableRule);
 | 
								query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid).AsTable(tableRule);
 | 
				
			||||||
@@ -745,7 +738,7 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule);
 | 
								query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule);
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								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` b ON b.`Guid` = a.`TypeGuid` AND b.`Name` = 'xxx' 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` WHERE (a__Type__Parent.`Id` = 10)", sql);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
								//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
				
			||||||
			query = select
 | 
								query = select
 | 
				
			||||||
@@ -758,7 +751,7 @@ namespace FreeSql.Tests.MySql {
 | 
				
			|||||||
				.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid)
 | 
									.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid)
 | 
				
			||||||
				.LeftJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId).AsTable(tableRule);
 | 
									.LeftJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId).AsTable(tableRule);
 | 
				
			||||||
			sql = query.ToSql().Replace("\r\n", "");
 | 
								sql = query.ToSql().Replace("\r\n", "");
 | 
				
			||||||
			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);
 | 
								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` a__Type ON a__Type.`Guid` = a.`TypeGuid` LEFT JOIN `TestTypeInfoAsTable2` b ON b.`Guid` = a.`TypeGuid` LEFT JOIN `TestTypeParentInfoAsTable` c ON c.`Id` = a__Type.`ParentId`", sql);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
 | 
								//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
 | 
				
			||||||
			var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
 | 
								var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,80 +35,112 @@ namespace FreeSql.Tests.MySqlExpression {
 | 
				
			|||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToBoolean() {
 | 
							public void ToBoolean() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 2) > 0).ToList());
 | 
								data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 0) > 0).ToList());
 | 
				
			||||||
			//SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` 
 | 
								data.Add(select.Where(a => (bool.Parse(a.Clicks.ToString()) ? 1 : 0) > 0).ToList());
 | 
				
			||||||
			//FROM `tb_topic` a 
 | 
					 | 
				
			||||||
			//WHERE ((a.`Clicks` not in ('0','false')))
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToByte() {
 | 
							public void ToByte() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToByte(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToByte(a.Clicks % 255) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => byte.Parse((a.Clicks % 255).ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToChar() {
 | 
							public void ToChar() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToBoolean(a.Clicks)).ToList());
 | 
								data.Add(select.Where(a => Convert.ToChar(a.Clicks) == '1').ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => char.Parse(a.Clicks.ToString()) == '1').ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDateTime() {
 | 
							public void ToDateTime() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDateTime(a.CreateTime.ToString()).Year > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDateTime(a.CreateTime.ToString()).Year > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => DateTime.Parse(a.CreateTime.ToString()).Year > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDecimal() {
 | 
							public void ToDecimal() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDecimal(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDecimal(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => decimal.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDouble() {
 | 
							public void ToDouble() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDouble(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDouble(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => double.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt16() {
 | 
							public void ToInt16() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt16(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt16(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => short.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt32() {
 | 
							public void ToInt32() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => (int)a.Clicks > 0).ToList());
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt32(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt32(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => int.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt64() {
 | 
							public void ToInt64() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt64(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt64(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => long.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToSByte() {
 | 
							public void ToSByte() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToSByte(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToSByte(a.Clicks % 128) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => sbyte.Parse((a.Clicks % 128).ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToSingle() {
 | 
							public void ToSingle() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToSingle(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToSingle(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => float.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void this_ToString() {
 | 
							public void this_ToString() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToString(a.Clicks).Equals("")).ToList());
 | 
								data.Add(select.Where(a => Convert.ToString(a.Clicks).Equals("")).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => a.Clicks.ToString().Equals("")).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt16() {
 | 
							public void ToUInt16() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt16(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt16(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => ushort.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt32() {
 | 
							public void ToUInt32() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt32(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt32(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => uint.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt64() {
 | 
							public void ToUInt64() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt64(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt64(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => ulong.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Guid_Parse() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => Guid.Parse(Guid.Empty.ToString()) == Guid.Empty).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Guid_NewGuid() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								//data.Add(select.OrderBy(a => Guid.NewGuid()).Limit(10).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Random() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => new Random().Next() > a.Clicks).Limit(10).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => new Random().NextDouble() > a.Clicks).Limit(10).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,81 +34,113 @@ namespace FreeSql.Tests.OracleExpression {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToBoolean() {
 | 
							public void ToBoolean() {
 | 
				
			||||||
			//var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			//data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 2) > 0).ToList());
 | 
								//data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 0) > 0).ToList());
 | 
				
			||||||
			//SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` 
 | 
								//data.Add(select.Where(a => (bool.Parse(a.Clicks.ToString()) ? 1 : 0) > 0).ToList());
 | 
				
			||||||
			//FROM `tb_topic` a 
 | 
					 | 
				
			||||||
			//WHERE ((a.`Clicks` not in ('0','false')))
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToByte() {
 | 
							public void ToByte() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToByte(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToByte(a.Clicks % 255) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => byte.Parse((a.Clicks % 255).ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToChar() {
 | 
							public void ToChar() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToChar(a.Clicks) == 'a').ToList());
 | 
								data.Add(select.Where(a => Convert.ToChar(a.Clicks) == '1').ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => char.Parse(a.Clicks.ToString()) == '1').ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDateTime() {
 | 
							public void ToDateTime() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDateTime(a.CreateTime.ToString()).Year > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDateTime(a.CreateTime.ToString()).Year > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => DateTime.Parse(a.CreateTime.ToString()).Year > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDecimal() {
 | 
							public void ToDecimal() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDecimal(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDecimal(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => decimal.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDouble() {
 | 
							public void ToDouble() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDouble(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDouble(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => double.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt16() {
 | 
							public void ToInt16() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt16(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt16(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => short.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt32() {
 | 
							public void ToInt32() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => (int)a.Clicks > 0).ToList());
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt32(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt32(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => int.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt64() {
 | 
							public void ToInt64() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt64(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt64(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => long.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToSByte() {
 | 
							public void ToSByte() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToSByte(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToSByte(a.Clicks % 128) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => sbyte.Parse((a.Clicks % 128).ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToSingle() {
 | 
							public void ToSingle() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToSingle(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToSingle(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => float.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void this_ToString() {
 | 
							public void this_ToString() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToString(a.Clicks).Equals("")).ToList());
 | 
								data.Add(select.Where(a => Convert.ToString(a.Clicks).Equals("")).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => a.Clicks.ToString().Equals("")).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt16() {
 | 
							public void ToUInt16() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt16(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt16(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => ushort.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt32() {
 | 
							public void ToUInt32() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt32(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt32(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => uint.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt64() {
 | 
							public void ToUInt64() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt64(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt64(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => ulong.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Guid_Parse() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => Guid.Parse(Guid.Empty.ToString()) == Guid.Empty).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Guid_NewGuid() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								//data.Add(select.OrderBy(a => Guid.NewGuid()).Limit(10).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Random() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => new Random().Next() > a.Clicks).Limit(10).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => new Random().NextDouble() > a.Clicks).Limit(10).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,80 +35,112 @@ namespace FreeSql.Tests.PostgreSQLExpression {
 | 
				
			|||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToBoolean() {
 | 
							public void ToBoolean() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 2) > 0).ToList());
 | 
								data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 0) > 0).ToList());
 | 
				
			||||||
			//SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` 
 | 
								data.Add(select.Where(a => (bool.Parse(a.Clicks.ToString()) ? 1 : 0) > 0).ToList());
 | 
				
			||||||
			//FROM `tb_topic` a 
 | 
					 | 
				
			||||||
			//WHERE ((a.`Clicks` not in ('0','false')))
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToByte() {
 | 
							public void ToByte() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToByte(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToByte(a.Clicks % 255) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => byte.Parse((a.Clicks % 255).ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToChar() {
 | 
							public void ToChar() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToBoolean(a.Clicks)).ToList());
 | 
								data.Add(select.Where(a => Convert.ToChar(a.Clicks) == '1').ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => char.Parse(a.Clicks.ToString()) == '1').ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDateTime() {
 | 
							public void ToDateTime() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDateTime(a.CreateTime.ToString()).Year > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDateTime(a.CreateTime.ToString()).Year > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => DateTime.Parse(a.CreateTime.ToString()).Year > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDecimal() {
 | 
							public void ToDecimal() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDecimal(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDecimal(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => decimal.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDouble() {
 | 
							public void ToDouble() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDouble(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDouble(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => double.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt16() {
 | 
							public void ToInt16() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt16(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt16(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => short.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt32() {
 | 
							public void ToInt32() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => (int)a.Clicks > 0).ToList());
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt32(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt32(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => int.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt64() {
 | 
							public void ToInt64() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt64(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt64(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => long.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToSByte() {
 | 
							public void ToSByte() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToSByte(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToSByte(a.Clicks % 128) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => sbyte.Parse((a.Clicks % 128).ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToSingle() {
 | 
							public void ToSingle() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToSingle(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToSingle(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => float.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void this_ToString() {
 | 
							public void this_ToString() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToString(a.Clicks).Equals("")).ToList());
 | 
								data.Add(select.Where(a => Convert.ToString(a.Clicks).Equals("")).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => a.Clicks.ToString().Equals("")).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt16() {
 | 
							public void ToUInt16() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt16(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt16(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => ushort.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt32() {
 | 
							public void ToUInt32() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt32(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt32(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => uint.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt64() {
 | 
							public void ToUInt64() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt64(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt64(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => ulong.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Guid_Parse() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => Guid.Parse(Guid.Empty.ToString()) == Guid.Empty).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Guid_NewGuid() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								//data.Add(select.OrderBy(a => Guid.NewGuid()).Limit(10).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Random() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => new Random().Next() > a.Clicks).Limit(10).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => new Random().NextDouble() > a.Clicks).Limit(10).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,76 +45,111 @@ namespace FreeSql.Tests.SqlServerExpression {
 | 
				
			|||||||
		public void ToBoolean() {
 | 
							public void ToBoolean() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 0) > 0).ToList());
 | 
								data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 0) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => (bool.Parse(a.Clicks.ToString()) ? 1 : 0) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToByte() {
 | 
							public void ToByte() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToByte(a.Clicks % 255) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToByte(a.Clicks % 255) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => byte.Parse((a.Clicks % 255).ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToChar() {
 | 
							public void ToChar() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToBoolean(a.Clicks)).ToList());
 | 
								data.Add(select.Where(a => Convert.ToChar(a.Clicks) == '1').ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => char.Parse(a.Clicks.ToString()) == '1').ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDateTime() {
 | 
							public void ToDateTime() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDateTime(a.CreateTime.ToString()).Year > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDateTime(a.CreateTime.ToString()).Year > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => DateTime.Parse(a.CreateTime.ToString()).Year > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDecimal() {
 | 
							public void ToDecimal() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDecimal(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDecimal(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => decimal.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDouble() {
 | 
							public void ToDouble() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDouble(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDouble(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => double.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt16() {
 | 
							public void ToInt16() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt16(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt16(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => short.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt32() {
 | 
							public void ToInt32() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => (int)a.Clicks > 0).ToList());
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt32(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt32(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => int.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt64() {
 | 
							public void ToInt64() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt64(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt64(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => long.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToSByte() {
 | 
							public void ToSByte() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToSByte(a.Clicks % 128) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToSByte(a.Clicks % 128) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => sbyte.Parse((a.Clicks % 128).ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToSingle() {
 | 
							public void ToSingle() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToSingle(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToSingle(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => float.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void this_ToString() {
 | 
							public void this_ToString() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToString(a.Clicks).Equals("")).ToList());
 | 
								data.Add(select.Where(a => Convert.ToString(a.Clicks).Equals("")).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => a.Clicks.ToString().Equals("")).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt16() {
 | 
							public void ToUInt16() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt16(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt16(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => ushort.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt32() {
 | 
							public void ToUInt32() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt32(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt32(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => uint.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt64() {
 | 
							public void ToUInt64() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt64(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt64(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => ulong.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Guid_Parse() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => Guid.Parse(Guid.NewGuid().ToString()) == Guid.Empty).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Guid_NewGuid() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.OrderBy(a => Guid.NewGuid()).Limit(10).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Random() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => new Random().Next() > a.Clicks).Limit(10).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => new Random().NextDouble() > a.Clicks).Limit(10).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,81 +34,113 @@ namespace FreeSql.Tests.SqliteExpression {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToBoolean() {
 | 
							public void ToBoolean() {
 | 
				
			||||||
			//var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			//data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 2) > 0).ToList());
 | 
								data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 0) > 0).ToList());
 | 
				
			||||||
			//SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` 
 | 
								data.Add(select.Where(a => (bool.Parse(a.Clicks.ToString()) ? 1 : 0) > 0).ToList());
 | 
				
			||||||
			//FROM `tb_topic` a 
 | 
					 | 
				
			||||||
			//WHERE ((a.`Clicks` not in ('0','false')))
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToByte() {
 | 
							public void ToByte() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToByte(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToByte(a.Clicks % 255) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => byte.Parse((a.Clicks % 255).ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToChar() {
 | 
							public void ToChar() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToChar(a.Clicks) == 'a').ToList());
 | 
								data.Add(select.Where(a => Convert.ToChar(a.Clicks) == '1').ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => char.Parse(a.Clicks.ToString()) == '1').ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDateTime() {
 | 
							public void ToDateTime() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDateTime(a.CreateTime.ToString()).Year > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDateTime(a.CreateTime.ToString()).Year > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => DateTime.Parse(a.CreateTime.ToString()).Year > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDecimal() {
 | 
							public void ToDecimal() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDecimal(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDecimal(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => decimal.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToDouble() {
 | 
							public void ToDouble() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToDouble(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToDouble(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => double.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt16() {
 | 
							public void ToInt16() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt16(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt16(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => short.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt32() {
 | 
							public void ToInt32() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => (int)a.Clicks > 0).ToList());
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt32(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt32(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => int.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToInt64() {
 | 
							public void ToInt64() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToInt64(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToInt64(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => long.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToSByte() {
 | 
							public void ToSByte() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToSByte(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToSByte(a.Clicks % 128) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => sbyte.Parse((a.Clicks % 128).ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToSingle() {
 | 
							public void ToSingle() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToSingle(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToSingle(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => float.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void this_ToString() {
 | 
							public void this_ToString() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToString(a.Clicks).Equals("")).ToList());
 | 
								data.Add(select.Where(a => Convert.ToString(a.Clicks).Equals("")).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => a.Clicks.ToString().Equals("")).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt16() {
 | 
							public void ToUInt16() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt16(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt16(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => ushort.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt32() {
 | 
							public void ToUInt32() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt32(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt32(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => uint.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
		public void ToUInt64() {
 | 
							public void ToUInt64() {
 | 
				
			||||||
			var data = new List<object>();
 | 
								var data = new List<object>();
 | 
				
			||||||
			data.Add(select.Where(a => Convert.ToUInt64(a.Clicks) > 0).ToList());
 | 
								data.Add(select.Where(a => Convert.ToUInt64(a.Clicks) > 0).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => ulong.Parse(a.Clicks.ToString()) > 0).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Guid_Parse() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => Guid.Parse(Guid.Empty.ToString()) == Guid.Empty).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Guid_NewGuid() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								//data.Add(select.OrderBy(a => Guid.NewGuid()).Limit(10).ToList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void Random() {
 | 
				
			||||||
 | 
								var data = new List<object>();
 | 
				
			||||||
 | 
								data.Add(select.Where(a => new Random().Next() > a.Clicks).Limit(10).ToList());
 | 
				
			||||||
 | 
								data.Add(select.Where(a => new Random().NextDouble() > a.Clicks).Limit(10).ToList());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -215,7 +215,10 @@ namespace FreeSql.Internal {
 | 
				
			|||||||
				case ExpressionType.Not: return $"not({ExpressionLambdaToSql((exp as UnaryExpression)?.Operand, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName)})";
 | 
									case ExpressionType.Not: return $"not({ExpressionLambdaToSql((exp as UnaryExpression)?.Operand, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName)})";
 | 
				
			||||||
				case ExpressionType.Quote: return ExpressionLambdaToSql((exp as UnaryExpression)?.Operand, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
									case ExpressionType.Quote: return ExpressionLambdaToSql((exp as UnaryExpression)?.Operand, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
				
			||||||
				case ExpressionType.Lambda: return ExpressionLambdaToSql((exp as LambdaExpression)?.Body, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
									case ExpressionType.Lambda: return ExpressionLambdaToSql((exp as LambdaExpression)?.Body, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
				
			||||||
				case ExpressionType.Convert: return ExpressionLambdaToSql((exp as UnaryExpression)?.Operand, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
									case ExpressionType.Convert:
 | 
				
			||||||
 | 
										var othercExp = ExpressionLambdaToSqlOther(exp, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
				
			||||||
 | 
										if (string.IsNullOrEmpty(othercExp) == false) return othercExp;
 | 
				
			||||||
 | 
										return ExpressionLambdaToSql((exp as UnaryExpression)?.Operand, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
				
			||||||
				case ExpressionType.Negate:
 | 
									case ExpressionType.Negate:
 | 
				
			||||||
				case ExpressionType.NegateChecked: return "-" + ExpressionLambdaToSql((exp as UnaryExpression)?.Operand, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
									case ExpressionType.NegateChecked: return "-" + ExpressionLambdaToSql((exp as UnaryExpression)?.Operand, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
				
			||||||
				case ExpressionType.Constant: return _common.FormatSql("{0}", (exp as ConstantExpression)?.Value);
 | 
									case ExpressionType.Constant: return _common.FormatSql("{0}", (exp as ConstantExpression)?.Value);
 | 
				
			||||||
@@ -461,7 +464,7 @@ namespace FreeSql.Internal {
 | 
				
			|||||||
					MethodCallExpression callExp = null;
 | 
										MethodCallExpression callExp = null;
 | 
				
			||||||
					var exp2 = exp4.Expression;
 | 
										var exp2 = exp4.Expression;
 | 
				
			||||||
					while (true) {
 | 
										while (true) {
 | 
				
			||||||
						switch(exp2.NodeType) {
 | 
											switch(exp2?.NodeType) {
 | 
				
			||||||
							case ExpressionType.Constant:
 | 
												case ExpressionType.Constant:
 | 
				
			||||||
								expStack.Push(exp2);
 | 
													expStack.Push(exp2);
 | 
				
			||||||
								break;
 | 
													break;
 | 
				
			||||||
@@ -514,6 +517,10 @@ namespace FreeSql.Internal {
 | 
				
			|||||||
								finds = _tables.Where(a2 => (isa && a2.Parameter != null || !isa && a2.Parameter == null) &&
 | 
													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}__") &&
 | 
														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();
 | 
														(isthis && a2.Type != SelectTableInfoType.Parent || !isthis && a2.Type == SelectTableInfoType.Parent)).ToArray();
 | 
				
			||||||
 | 
													if (finds.Length == 0)
 | 
				
			||||||
 | 
														finds = _tables.Where(a2 => 
 | 
				
			||||||
 | 
															 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 {
 | 
												} else {
 | 
				
			||||||
								finds = _tables.Where(a2 => (isa && a2.Parameter != null || isa && a2.Parameter == null) &&
 | 
													finds = _tables.Where(a2 => (isa && a2.Parameter != null || isa && a2.Parameter == null) &&
 | 
				
			||||||
									a2.Table.Type == tbtmp.Type && a2.Alias == alias).ToArray();
 | 
														a2.Table.Type == tbtmp.Type && a2.Alias == alias).ToArray();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,8 +15,67 @@ namespace FreeSql.MySql {
 | 
				
			|||||||
		internal override string ExpressionLambdaToSqlOther(Expression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
 | 
							internal override string ExpressionLambdaToSqlOther(Expression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
 | 
				
			||||||
			Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
								Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
				
			||||||
			switch (exp.NodeType) {
 | 
								switch (exp.NodeType) {
 | 
				
			||||||
 | 
									case ExpressionType.Convert:
 | 
				
			||||||
 | 
										var operandExp = (exp as UnaryExpression)?.Operand;
 | 
				
			||||||
 | 
										switch (exp.Type.NullableTypeOrThis().ToString()) {
 | 
				
			||||||
 | 
											case "System.Boolean": return $"({getExp(operandExp)} not in ('0','false'))";
 | 
				
			||||||
 | 
											case "System.Byte": return $"cast({getExp(operandExp)} as unsigned)";
 | 
				
			||||||
 | 
											case "System.Char": return $"substr(cast({getExp(operandExp)} as char), 1, 1)";
 | 
				
			||||||
 | 
											case "System.DateTime": return $"cast({getExp(operandExp)} as datetime)";
 | 
				
			||||||
 | 
											case "System.Decimal": return $"cast({getExp(operandExp)} as decimal(36,18))";
 | 
				
			||||||
 | 
											case "System.Double": return $"cast({getExp(operandExp)} as decimal(32,16))";
 | 
				
			||||||
 | 
											case "System.Int16":
 | 
				
			||||||
 | 
											case "System.Int32":
 | 
				
			||||||
 | 
											case "System.Int64":
 | 
				
			||||||
 | 
											case "System.SByte": return $"cast({getExp(operandExp)} as signed)";
 | 
				
			||||||
 | 
											case "System.Single": return $"cast({getExp(operandExp)} as decimal(14,7))";
 | 
				
			||||||
 | 
											case "System.String": return $"cast({getExp(operandExp)} as char)";
 | 
				
			||||||
 | 
											case "System.UInt16":
 | 
				
			||||||
 | 
											case "System.UInt32":
 | 
				
			||||||
 | 
											case "System.UInt64": return $"cast({getExp(operandExp)} as unsigned)";
 | 
				
			||||||
 | 
											case "System.Guid": return $"substr(cast({getExp(operandExp)} as char), 1, 36)";
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
				case ExpressionType.Call:
 | 
									case ExpressionType.Call:
 | 
				
			||||||
					var callExp = exp as MethodCallExpression;
 | 
										var callExp = exp as MethodCallExpression;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										switch (callExp.Method.Name) {
 | 
				
			||||||
 | 
											case "Parse":
 | 
				
			||||||
 | 
											case "TryParse":
 | 
				
			||||||
 | 
												switch (callExp.Method.DeclaringType.NullableTypeOrThis().ToString()) {
 | 
				
			||||||
 | 
													case "System.Boolean": return $"({getExp(callExp.Arguments[0])} not in ('0','false'))";
 | 
				
			||||||
 | 
													case "System.Byte": return $"cast({getExp(callExp.Arguments[0])} as unsigned)";
 | 
				
			||||||
 | 
													case "System.Char": return $"substr(cast({getExp(callExp.Arguments[0])} as char), 1, 1)";
 | 
				
			||||||
 | 
													case "System.DateTime": return $"cast({getExp(callExp.Arguments[0])} as datetime)";
 | 
				
			||||||
 | 
													case "System.Decimal": return $"cast({getExp(callExp.Arguments[0])} as decimal(36,18))";
 | 
				
			||||||
 | 
													case "System.Double": return $"cast({getExp(callExp.Arguments[0])} as decimal(32,16))";
 | 
				
			||||||
 | 
													case "System.Int16":
 | 
				
			||||||
 | 
													case "System.Int32":
 | 
				
			||||||
 | 
													case "System.Int64":
 | 
				
			||||||
 | 
													case "System.SByte": return $"cast({getExp(callExp.Arguments[0])} as signed)";
 | 
				
			||||||
 | 
													case "System.Single": return $"cast({getExp(callExp.Arguments[0])} as decimal(14,7))";
 | 
				
			||||||
 | 
													case "System.UInt16":
 | 
				
			||||||
 | 
													case "System.UInt32":
 | 
				
			||||||
 | 
													case "System.UInt64": return $"cast({getExp(callExp.Arguments[0])} as unsigned)";
 | 
				
			||||||
 | 
													case "System.Guid": return $"substr(cast({getExp(callExp.Arguments[0])} as char), 1, 36)";
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "NewGuid":
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "Next":
 | 
				
			||||||
 | 
												if (callExp.Object?.Type == typeof(Random)) return "cast(rand()*1000000000 as signed)";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "NextDouble":
 | 
				
			||||||
 | 
												if (callExp.Object?.Type == typeof(Random)) return "rand()";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "Random":
 | 
				
			||||||
 | 
												if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "ToString":
 | 
				
			||||||
 | 
												if (callExp.Object != null) return $"cast({getExp(callExp.Object)} as char)";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					var objExp = callExp.Object;
 | 
										var objExp = callExp.Object;
 | 
				
			||||||
					var objType = objExp?.Type;
 | 
										var objType = objExp?.Type;
 | 
				
			||||||
					if (objType?.FullName == "System.Byte[]") return null;
 | 
										if (objType?.FullName == "System.Byte[]") return null;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,8 +15,67 @@ namespace FreeSql.Oracle {
 | 
				
			|||||||
		internal override string ExpressionLambdaToSqlOther(Expression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
 | 
							internal override string ExpressionLambdaToSqlOther(Expression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
 | 
				
			||||||
			Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
								Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
				
			||||||
			switch (exp.NodeType) {
 | 
								switch (exp.NodeType) {
 | 
				
			||||||
 | 
									case ExpressionType.Convert:
 | 
				
			||||||
 | 
										var operandExp = (exp as UnaryExpression)?.Operand;
 | 
				
			||||||
 | 
										switch (exp.Type.NullableTypeOrThis().ToString()) {
 | 
				
			||||||
 | 
											//case "System.Boolean": return $"({getExp(operandExp)} not in ('0','false'))";
 | 
				
			||||||
 | 
											case "System.Byte": return $"cast({getExp(operandExp)} as number)";
 | 
				
			||||||
 | 
											case "System.Char": return $"substr(to_char({getExp(operandExp)}), 1, 1)";
 | 
				
			||||||
 | 
											case "System.DateTime": return $"to_timestamp({getExp(operandExp)},'YYYY-MM-DD HH24:MI:SS.FF6')";
 | 
				
			||||||
 | 
											case "System.Decimal": return $"cast({getExp(operandExp)} as number)";
 | 
				
			||||||
 | 
											case "System.Double": return $"cast({getExp(operandExp)} as number)";
 | 
				
			||||||
 | 
											case "System.Int16":
 | 
				
			||||||
 | 
											case "System.Int32":
 | 
				
			||||||
 | 
											case "System.Int64":
 | 
				
			||||||
 | 
											case "System.SByte": return $"cast({getExp(operandExp)} as number)";
 | 
				
			||||||
 | 
											case "System.Single": return $"cast({getExp(operandExp)} as number)";
 | 
				
			||||||
 | 
											case "System.String": return $"to_char({getExp(operandExp)})";
 | 
				
			||||||
 | 
											case "System.UInt16":
 | 
				
			||||||
 | 
											case "System.UInt32":
 | 
				
			||||||
 | 
											case "System.UInt64": return $"cast({getExp(operandExp)} as number)";
 | 
				
			||||||
 | 
											case "System.Guid": return $"substr(to_char({getExp(operandExp)}), 1, 36)";
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
				case ExpressionType.Call:
 | 
									case ExpressionType.Call:
 | 
				
			||||||
					var callExp = exp as MethodCallExpression;
 | 
										var callExp = exp as MethodCallExpression;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										switch (callExp.Method.Name) {
 | 
				
			||||||
 | 
											case "Parse":
 | 
				
			||||||
 | 
											case "TryParse":
 | 
				
			||||||
 | 
												switch (callExp.Method.DeclaringType.NullableTypeOrThis().ToString()) {
 | 
				
			||||||
 | 
													//case "System.Boolean": return $"({getExp(callExp.Arguments[0])} not in ('0','false'))";
 | 
				
			||||||
 | 
													case "System.Byte": return $"cast({getExp(callExp.Arguments[0])} as number)";
 | 
				
			||||||
 | 
													case "System.Char": return $"substr(to_char({getExp(callExp.Arguments[0])}), 1, 1)";
 | 
				
			||||||
 | 
													case "System.DateTime": return $"to_timestamp({getExp(callExp.Arguments[0])},'YYYY-MM-DD HH24:MI:SS.FF6')";
 | 
				
			||||||
 | 
													case "System.Decimal": return $"cast({getExp(callExp.Arguments[0])} as number)";
 | 
				
			||||||
 | 
													case "System.Double": return $"cast({getExp(callExp.Arguments[0])} as number)";
 | 
				
			||||||
 | 
													case "System.Int16":
 | 
				
			||||||
 | 
													case "System.Int32":
 | 
				
			||||||
 | 
													case "System.Int64":
 | 
				
			||||||
 | 
													case "System.SByte": return $"cast({getExp(callExp.Arguments[0])} as number)";
 | 
				
			||||||
 | 
													case "System.Single": return $"cast({getExp(callExp.Arguments[0])} as number)";
 | 
				
			||||||
 | 
													case "System.UInt16":
 | 
				
			||||||
 | 
													case "System.UInt32":
 | 
				
			||||||
 | 
													case "System.UInt64": return $"cast({getExp(callExp.Arguments[0])} as number)";
 | 
				
			||||||
 | 
													case "System.Guid": return $"substr(to_char({getExp(callExp.Arguments[0])}), 1, 36)";
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "NewGuid":
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "Next":
 | 
				
			||||||
 | 
												if (callExp.Object?.Type == typeof(Random)) return "cast(dbms_random.value*1000000000 as smallint)";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "NextDouble":
 | 
				
			||||||
 | 
												if (callExp.Object?.Type == typeof(Random)) return "dbms_random.value";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "Random":
 | 
				
			||||||
 | 
												if (callExp.Method.DeclaringType.IsNumberType()) return "dbms_random.value";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "ToString":
 | 
				
			||||||
 | 
												if (callExp.Object != null) return $"to_char({getExp(callExp.Object)})";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					var objExp = callExp.Object;
 | 
										var objExp = callExp.Object;
 | 
				
			||||||
					var objType = objExp?.Type;
 | 
										var objType = objExp?.Type;
 | 
				
			||||||
					if (objType?.FullName == "System.Byte[]") return null;
 | 
										if (objType?.FullName == "System.Byte[]") return null;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,12 +16,71 @@ namespace FreeSql.PostgreSQL {
 | 
				
			|||||||
		internal override string ExpressionLambdaToSqlOther(Expression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
 | 
							internal override string ExpressionLambdaToSqlOther(Expression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
 | 
				
			||||||
			Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
								Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
				
			||||||
			switch (exp.NodeType) {
 | 
								switch (exp.NodeType) {
 | 
				
			||||||
 | 
									case ExpressionType.Convert:
 | 
				
			||||||
 | 
										var operandExp = (exp as UnaryExpression)?.Operand;
 | 
				
			||||||
 | 
										switch (exp.Type.NullableTypeOrThis().ToString()) {
 | 
				
			||||||
 | 
											case "System.Boolean": return $"(({getExp(operandExp)})::varchar not in ('0','false','f','no'))";
 | 
				
			||||||
 | 
											case "System.Byte": return $"({getExp(operandExp)})::int2";
 | 
				
			||||||
 | 
											case "System.Char": return $"substr(({getExp(operandExp)})::char, 1, 1)";
 | 
				
			||||||
 | 
											case "System.DateTime": return $"({getExp(operandExp)})::timestamp";
 | 
				
			||||||
 | 
											case "System.Decimal": return $"({getExp(operandExp)})::numeric";
 | 
				
			||||||
 | 
											case "System.Double": return $"({getExp(operandExp)})::float8";
 | 
				
			||||||
 | 
											case "System.Int16": return $"({getExp(operandExp)})::int2";
 | 
				
			||||||
 | 
											case "System.Int32": return $"({getExp(operandExp)})::int4";
 | 
				
			||||||
 | 
											case "System.Int64": return $"({getExp(operandExp)})::int8";
 | 
				
			||||||
 | 
											case "System.SByte": return $"({getExp(operandExp)})::int2";
 | 
				
			||||||
 | 
											case "System.Single": return $"({getExp(operandExp)})::float4";
 | 
				
			||||||
 | 
											case "System.String": return $"({getExp(operandExp)})::varchar";
 | 
				
			||||||
 | 
											case "System.UInt16": return $"({getExp(operandExp)})::int2";
 | 
				
			||||||
 | 
											case "System.UInt32": return $"({getExp(operandExp)})::int4";
 | 
				
			||||||
 | 
											case "System.UInt64": return $"({getExp(operandExp)})::int8";
 | 
				
			||||||
 | 
											case "System.Guid": return $"({getExp(operandExp)})::uuid";
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
				case ExpressionType.ArrayLength:
 | 
									case ExpressionType.ArrayLength:
 | 
				
			||||||
					var arrOperExp = getExp((exp as UnaryExpression).Operand);
 | 
										var arrOperExp = getExp((exp as UnaryExpression).Operand);
 | 
				
			||||||
					if (arrOperExp.StartsWith("(") || arrOperExp.EndsWith(")")) return $"array_length(array[{arrOperExp.TrimStart('(').TrimEnd(')')}],1)";
 | 
										if (arrOperExp.StartsWith("(") || arrOperExp.EndsWith(")")) return $"array_length(array[{arrOperExp.TrimStart('(').TrimEnd(')')}],1)";
 | 
				
			||||||
					return $"case when {arrOperExp} is null then 0 else array_length({arrOperExp},1) end";
 | 
										return $"case when {arrOperExp} is null then 0 else array_length({arrOperExp},1) end";
 | 
				
			||||||
				case ExpressionType.Call:
 | 
									case ExpressionType.Call:
 | 
				
			||||||
					var callExp = exp as MethodCallExpression;
 | 
										var callExp = exp as MethodCallExpression;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										switch (callExp.Method.Name) {
 | 
				
			||||||
 | 
											case "Parse":
 | 
				
			||||||
 | 
											case "TryParse":
 | 
				
			||||||
 | 
												switch (callExp.Method.DeclaringType.NullableTypeOrThis().ToString()) {
 | 
				
			||||||
 | 
													case "System.Boolean": return $"(({getExp(callExp.Arguments[0])})::varchar not in ('0','false','f','no'))";
 | 
				
			||||||
 | 
													case "System.Byte": return $"({getExp(callExp.Arguments[0])})::int2";
 | 
				
			||||||
 | 
													case "System.Char": return $"substr(({getExp(callExp.Arguments[0])})::char, 1, 1)";
 | 
				
			||||||
 | 
													case "System.DateTime": return $"({getExp(callExp.Arguments[0])})::timestamp";
 | 
				
			||||||
 | 
													case "System.Decimal": return $"({getExp(callExp.Arguments[0])})::numeric";
 | 
				
			||||||
 | 
													case "System.Double": return $"({getExp(callExp.Arguments[0])})::float8";
 | 
				
			||||||
 | 
													case "System.Int16": return $"({getExp(callExp.Arguments[0])})::int2";
 | 
				
			||||||
 | 
													case "System.Int32": return $"({getExp(callExp.Arguments[0])})::int4";
 | 
				
			||||||
 | 
													case "System.Int64": return $"({getExp(callExp.Arguments[0])})::int8";
 | 
				
			||||||
 | 
													case "System.SByte": return $"({getExp(callExp.Arguments[0])})::int2";
 | 
				
			||||||
 | 
													case "System.Single": return $"({getExp(callExp.Arguments[0])})::float4";
 | 
				
			||||||
 | 
													case "System.UInt16": return $"({getExp(callExp.Arguments[0])})::int2";
 | 
				
			||||||
 | 
													case "System.UInt32": return $"({getExp(callExp.Arguments[0])})::int4";
 | 
				
			||||||
 | 
													case "System.UInt64": return $"({getExp(callExp.Arguments[0])})::int8";
 | 
				
			||||||
 | 
													case "System.Guid": return $"({getExp(callExp.Arguments[0])})::uuid";
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "NewGuid":
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "Next":
 | 
				
			||||||
 | 
												if (callExp.Object?.Type == typeof(Random)) return "(random()*1000000000)::int4";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "NextDouble":
 | 
				
			||||||
 | 
												if (callExp.Object?.Type == typeof(Random)) return "random()";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "Random":
 | 
				
			||||||
 | 
												if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "ToString":
 | 
				
			||||||
 | 
												if (callExp.Object != null) return $"({getExp(callExp.Object)})::varchar";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					var objExp = callExp.Object;
 | 
										var objExp = callExp.Object;
 | 
				
			||||||
					var objType = objExp?.Type;
 | 
										var objType = objExp?.Type;
 | 
				
			||||||
					if (objType?.FullName == "System.Byte[]") return null;
 | 
										if (objType?.FullName == "System.Byte[]") return null;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,8 +15,70 @@ namespace FreeSql.SqlServer {
 | 
				
			|||||||
		internal override string ExpressionLambdaToSqlOther(Expression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
 | 
							internal override string ExpressionLambdaToSqlOther(Expression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
 | 
				
			||||||
			Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
								Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
				
			||||||
			switch (exp.NodeType) {
 | 
								switch (exp.NodeType) {
 | 
				
			||||||
 | 
									case ExpressionType.Convert:
 | 
				
			||||||
 | 
										var operandExp = (exp as UnaryExpression)?.Operand;
 | 
				
			||||||
 | 
										switch (exp.Type.NullableTypeOrThis().ToString()) {
 | 
				
			||||||
 | 
											case "System.Boolean": return $"(cast({getExp(operandExp)} as varchar) not in ('0','false'))";
 | 
				
			||||||
 | 
											case "System.Byte": return $"cast({getExp(operandExp)} as tinyint)";
 | 
				
			||||||
 | 
											case "System.Char": return $"substring(cast({getExp(operandExp)} as nvarchar),1,1)";
 | 
				
			||||||
 | 
											case "System.DateTime": return $"cast({getExp(operandExp)} as datetime)";
 | 
				
			||||||
 | 
											case "System.Decimal": return $"cast({getExp(operandExp)} as decimal(36,18))";
 | 
				
			||||||
 | 
											case "System.Double": return $"cast({getExp(operandExp)} as decimal(32,16))";
 | 
				
			||||||
 | 
											case "System.Int16": return $"cast({getExp(operandExp)} as smallint)";
 | 
				
			||||||
 | 
											case "System.Int32": return $"cast({getExp(operandExp)} as int)";
 | 
				
			||||||
 | 
											case "System.Int64": return $"cast({getExp(operandExp)} as bigint)";
 | 
				
			||||||
 | 
											case "System.SByte": return $"cast({getExp(operandExp)} as tinyint)";
 | 
				
			||||||
 | 
											case "System.Single": return $"cast({getExp(operandExp)} as decimal(14,7))";
 | 
				
			||||||
 | 
											case "System.String": return operandExp.Type.NullableTypeOrThis() == typeof(Guid) ? $"cast({getExp(operandExp)} as varchar(36))" : $"cast({getExp(operandExp)} as nvarchar)";
 | 
				
			||||||
 | 
											case "System.UInt16": return $"cast({getExp(operandExp)} as smallint)";
 | 
				
			||||||
 | 
											case "System.UInt32": return $"cast({getExp(operandExp)} as int)";
 | 
				
			||||||
 | 
											case "System.UInt64": return $"cast({getExp(operandExp)} as bigint)";
 | 
				
			||||||
 | 
											case "System.Guid": return $"cast({getExp(operandExp)} as uniqueidentifier)";
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
				case ExpressionType.Call:
 | 
									case ExpressionType.Call:
 | 
				
			||||||
					var callExp = exp as MethodCallExpression;
 | 
										var callExp = exp as MethodCallExpression;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										switch(callExp.Method.Name) {
 | 
				
			||||||
 | 
											case "Parse":
 | 
				
			||||||
 | 
											case "TryParse":
 | 
				
			||||||
 | 
												switch (callExp.Method.DeclaringType.NullableTypeOrThis().ToString()) {
 | 
				
			||||||
 | 
													case "System.Boolean": return $"(cast({getExp(callExp.Arguments[0])} as varchar) not in ('0','false'))";
 | 
				
			||||||
 | 
													case "System.Byte": return $"cast({getExp(callExp.Arguments[0])} as tinyint)";
 | 
				
			||||||
 | 
													case "System.Char": return $"substring(cast({getExp(callExp.Arguments[0])} as nvarchar),1,1)";
 | 
				
			||||||
 | 
													case "System.DateTime": return $"cast({getExp(callExp.Arguments[0])} as datetime)";
 | 
				
			||||||
 | 
													case "System.Decimal": return $"cast({getExp(callExp.Arguments[0])} as decimal(36,18))";
 | 
				
			||||||
 | 
													case "System.Double": return $"cast({getExp(callExp.Arguments[0])} as decimal(32,16))";
 | 
				
			||||||
 | 
													case "System.Int16": return $"cast({getExp(callExp.Arguments[0])} as smallint)";
 | 
				
			||||||
 | 
													case "System.Int32": return $"cast({getExp(callExp.Arguments[0])} as int)";
 | 
				
			||||||
 | 
													case "System.Int64": return $"cast({getExp(callExp.Arguments[0])} as bigint)";
 | 
				
			||||||
 | 
													case "System.SByte": return $"cast({getExp(callExp.Arguments[0])} as tinyint)";
 | 
				
			||||||
 | 
													case "System.Single": return $"cast({getExp(callExp.Arguments[0])} as decimal(14,7))";
 | 
				
			||||||
 | 
													case "System.UInt16": return $"cast({getExp(callExp.Arguments[0])} as smallint)";
 | 
				
			||||||
 | 
													case "System.UInt32": return $"cast({getExp(callExp.Arguments[0])} as int)";
 | 
				
			||||||
 | 
													case "System.UInt64": return $"cast({getExp(callExp.Arguments[0])} as bigint)";
 | 
				
			||||||
 | 
													case "System.Guid": return $"cast({getExp(callExp.Arguments[0])} as uniqueidentifier)";
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "NewGuid":
 | 
				
			||||||
 | 
												switch (callExp.Method.DeclaringType.NullableTypeOrThis().ToString()) {
 | 
				
			||||||
 | 
													case "System.Guid": return $"newid()";
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "Next":
 | 
				
			||||||
 | 
												if (callExp.Object?.Type == typeof(Random)) return "cast(rand()*1000000000 as int)";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "NextDouble":
 | 
				
			||||||
 | 
												if (callExp.Object?.Type == typeof(Random)) return "rand()";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "Random":
 | 
				
			||||||
 | 
												if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "ToString":
 | 
				
			||||||
 | 
												if (callExp.Object != null) return callExp.Object.Type.NullableTypeOrThis() == typeof(Guid) ? $"cast({getExp(callExp.Object)} as varchar(36))" : $"cast({getExp(callExp.Object)} as nvarchar)";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					var objExp = callExp.Object;
 | 
										var objExp = callExp.Object;
 | 
				
			||||||
					var objType = objExp?.Type;
 | 
										var objType = objExp?.Type;
 | 
				
			||||||
					if (objType?.FullName == "System.Byte[]") return null;
 | 
										if (objType?.FullName == "System.Byte[]") return null;
 | 
				
			||||||
@@ -306,7 +368,7 @@ namespace FreeSql.SqlServer {
 | 
				
			|||||||
					case "ToInt64": return $"cast({getExp(exp.Arguments[0])} as bigint)";
 | 
										case "ToInt64": return $"cast({getExp(exp.Arguments[0])} as bigint)";
 | 
				
			||||||
					case "ToSByte": return $"cast({getExp(exp.Arguments[0])} as tinyint)";
 | 
										case "ToSByte": return $"cast({getExp(exp.Arguments[0])} as tinyint)";
 | 
				
			||||||
					case "ToSingle": return $"cast({getExp(exp.Arguments[0])} as decimal(14,7))";
 | 
										case "ToSingle": return $"cast({getExp(exp.Arguments[0])} as decimal(14,7))";
 | 
				
			||||||
					case "ToString": return $"cast({getExp(exp.Arguments[0])} as nvarchar)";
 | 
										case "ToString": return exp.Arguments[0].Type.NullableTypeOrThis() == typeof(Guid) ? $"cast({getExp(exp.Arguments[0])} as varchar(36))" : $"cast({getExp(exp.Arguments[0])} as nvarchar)";
 | 
				
			||||||
					case "ToUInt16": return $"cast({getExp(exp.Arguments[0])} as smallint)";
 | 
										case "ToUInt16": return $"cast({getExp(exp.Arguments[0])} as smallint)";
 | 
				
			||||||
					case "ToUInt32": return $"cast({getExp(exp.Arguments[0])} as int)";
 | 
										case "ToUInt32": return $"cast({getExp(exp.Arguments[0])} as int)";
 | 
				
			||||||
					case "ToUInt64": return $"cast({getExp(exp.Arguments[0])} as bigint)";
 | 
										case "ToUInt64": return $"cast({getExp(exp.Arguments[0])} as bigint)";
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,8 +15,67 @@ namespace FreeSql.Sqlite {
 | 
				
			|||||||
		internal override string ExpressionLambdaToSqlOther(Expression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
 | 
							internal override string ExpressionLambdaToSqlOther(Expression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
 | 
				
			||||||
			Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
								Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
 | 
				
			||||||
			switch (exp.NodeType) {
 | 
								switch (exp.NodeType) {
 | 
				
			||||||
 | 
									case ExpressionType.Convert:
 | 
				
			||||||
 | 
										var operandExp = (exp as UnaryExpression)?.Operand;
 | 
				
			||||||
 | 
										switch (exp.Type.NullableTypeOrThis().ToString()) {
 | 
				
			||||||
 | 
											case "System.Boolean": return $"({getExp(operandExp)} not in ('0','false'))";
 | 
				
			||||||
 | 
											case "System.Byte": return $"cast({getExp(operandExp)} as int2)";
 | 
				
			||||||
 | 
											case "System.Char": return $"substr(cast({getExp(operandExp)} as character), 1, 1)";
 | 
				
			||||||
 | 
											case "System.DateTime": return $"datetime({getExp(operandExp)})";
 | 
				
			||||||
 | 
											case "System.Decimal": return $"cast({getExp(operandExp)} as decimal(36,18))";
 | 
				
			||||||
 | 
											case "System.Double": return $"cast({getExp(operandExp)} as double)";
 | 
				
			||||||
 | 
											case "System.Int16":
 | 
				
			||||||
 | 
											case "System.Int32":
 | 
				
			||||||
 | 
											case "System.Int64":
 | 
				
			||||||
 | 
											case "System.SByte": return $"cast({getExp(operandExp)} as smallint)";
 | 
				
			||||||
 | 
											case "System.Single": return $"cast({getExp(operandExp)} as float)";
 | 
				
			||||||
 | 
											case "System.String": return $"cast({getExp(operandExp)} as character)";
 | 
				
			||||||
 | 
											case "System.UInt16": return $"cast({getExp(operandExp)} as unsigned)";
 | 
				
			||||||
 | 
											case "System.UInt32": return $"cast({getExp(operandExp)} as decimal(10,0))";
 | 
				
			||||||
 | 
											case "System.UInt64": return $"cast({getExp(operandExp)} as decimal(21,0))";
 | 
				
			||||||
 | 
											case "System.Guid": return $"substr(cast({getExp(operandExp)} as character), 1, 36)";
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
				case ExpressionType.Call:
 | 
									case ExpressionType.Call:
 | 
				
			||||||
					var callExp = exp as MethodCallExpression;
 | 
										var callExp = exp as MethodCallExpression;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										switch (callExp.Method.Name) {
 | 
				
			||||||
 | 
											case "Parse":
 | 
				
			||||||
 | 
											case "TryParse":
 | 
				
			||||||
 | 
												switch (callExp.Method.DeclaringType.NullableTypeOrThis().ToString()) {
 | 
				
			||||||
 | 
													case "System.Boolean": return $"({getExp(callExp.Arguments[0])} not in ('0','false'))";
 | 
				
			||||||
 | 
													case "System.Byte": return $"cast({getExp(callExp.Arguments[0])} as int2)";
 | 
				
			||||||
 | 
													case "System.Char": return $"substr(cast({getExp(callExp.Arguments[0])} as character), 1, 1)";
 | 
				
			||||||
 | 
													case "System.DateTime": return $"datetime({getExp(callExp.Arguments[0])})";
 | 
				
			||||||
 | 
													case "System.Decimal": return $"cast({getExp(callExp.Arguments[0])} as decimal(36,18))";
 | 
				
			||||||
 | 
													case "System.Double": return $"cast({getExp(callExp.Arguments[0])} as double)";
 | 
				
			||||||
 | 
													case "System.Int16":
 | 
				
			||||||
 | 
													case "System.Int32":
 | 
				
			||||||
 | 
													case "System.Int64":
 | 
				
			||||||
 | 
													case "System.SByte": return $"cast({getExp(callExp.Arguments[0])} as smallint)";
 | 
				
			||||||
 | 
													case "System.Single": return $"cast({getExp(callExp.Arguments[0])} as float)";
 | 
				
			||||||
 | 
													case "System.UInt16": return $"cast({getExp(callExp.Arguments[0])} as unsigned)";
 | 
				
			||||||
 | 
													case "System.UInt32": return $"cast({getExp(callExp.Arguments[0])} as decimal(10,0))";
 | 
				
			||||||
 | 
													case "System.UInt64": return $"cast({getExp(callExp.Arguments[0])} as decimal(21,0))";
 | 
				
			||||||
 | 
													case "System.Guid": return $"substr(cast({getExp(callExp.Arguments[0])} as character), 1, 36)";
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "NewGuid":
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "Next":
 | 
				
			||||||
 | 
												if (callExp.Object?.Type == typeof(Random)) return "cast(random()*1000000000 as int)";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "NextDouble":
 | 
				
			||||||
 | 
												if (callExp.Object?.Type == typeof(Random)) return "random()";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "Random":
 | 
				
			||||||
 | 
												if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case "ToString":
 | 
				
			||||||
 | 
												if (callExp.Object != null) return $"cast({getExp(callExp.Object)} as character)";
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					var objExp = callExp.Object;
 | 
										var objExp = callExp.Object;
 | 
				
			||||||
					var objType = objExp?.Type;
 | 
										var objType = objExp?.Type;
 | 
				
			||||||
					if (objType?.FullName == "System.Byte[]") return null;
 | 
										if (objType?.FullName == "System.Byte[]") return null;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user