mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-01 00:05:28 +08:00 
			
		
		
		
	- 适配 FreeSql.Provider.MySqlConnector,和它对应的266个单元测试;
This commit is contained in:
		| @@ -0,0 +1,21 @@ | ||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||
|  | ||||
|   <PropertyGroup> | ||||
|     <TargetFramework>netcoreapp2.2</TargetFramework> | ||||
|  | ||||
|     <IsPackable>false</IsPackable> | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> | ||||
|     <PackageReference Include="xunit" Version="2.4.0" /> | ||||
|     <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <ProjectReference Include="..\Extensions\FreeSql.Extensions.LazyLoading\FreeSql.Extensions.LazyLoading.csproj" /> | ||||
|     <ProjectReference Include="..\FreeSql\FreeSql.csproj" /> | ||||
|     <ProjectReference Include="..\Providers\FreeSql.Provider.MySqlConnector\FreeSql.Provider.MySqlConnector.csproj" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
| </Project> | ||||
| @@ -0,0 +1,87 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnector { | ||||
| 	public class MySqlDeleteTest { | ||||
|  | ||||
| 		IDelete<Topic> delete => g.mysql.Delete<Topic>(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| 		[Table(Name = "tb_topic")] | ||||
| 		class Topic { | ||||
| 			[Column(IsIdentity = true, IsPrimary = true)] | ||||
| 			public int Id { get; set; } | ||||
| 			public int Clicks { get; set; } | ||||
| 			public string Title { get; set; } | ||||
| 			public DateTime CreateTime { get; set; } | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void Dywhere() { | ||||
| 			Assert.Null(g.mysql.Delete<Topic>().ToSql()); | ||||
| 			var sql = g.mysql.Delete<Topic>(new[] { 1, 2 }).ToSql(); | ||||
| 			Assert.Equal("DELETE FROM `tb_topic` WHERE (`Id` = 1 OR `Id` = 2)", sql); | ||||
|  | ||||
| 			sql = g.mysql.Delete<Topic>(new Topic { Id = 1, Title = "test" }).ToSql(); | ||||
| 			Assert.Equal("DELETE FROM `tb_topic` WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = g.mysql.Delete<Topic>(new[] { new Topic { Id = 1, Title = "test" }, new Topic { Id = 2, Title = "test" } }).ToSql(); | ||||
| 			Assert.Equal("DELETE FROM `tb_topic` WHERE (`Id` = 1 OR `Id` = 2)", sql); | ||||
|  | ||||
| 			sql = g.mysql.Delete<Topic>(new { id = 1 }).ToSql(); | ||||
| 			Assert.Equal("DELETE FROM `tb_topic` WHERE (`Id` = 1)", sql); | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void Where() { | ||||
| 			var sql = delete.Where(a => a.Id == 1).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM `tb_topic` WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = delete.Where("id = @id", new { id = 1 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM `tb_topic` WHERE (id = @id)", sql); | ||||
|  | ||||
| 			var item = new Topic { Id = 1, Title = "newtitle" }; | ||||
| 			sql = delete.Where(item).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM `tb_topic` WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			var items = new List<Topic>(); | ||||
| 			for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 }); | ||||
|  | ||||
| 			sql = delete.Where(items).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM `tb_topic` WHERE (`Id` IN (1,2,3,4,5,6,7,8,9,10))", sql); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void WhereExists() { | ||||
|  | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ExecuteAffrows() { | ||||
|  | ||||
| 			var id = g.mysql.Insert<Topic>(new Topic { Title = "xxxx" }).ExecuteIdentity(); | ||||
| 			Assert.Equal(1, delete.Where(a => a.Id == id).ExecuteAffrows()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ExecuteDeleted() { | ||||
|  | ||||
| 			//delete.Where(a => a.Id > 0).ExecuteDeleted(); | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void AsTable() { | ||||
| 			Assert.Null(g.mysql.Delete<Topic>().ToSql()); | ||||
| 			var sql = g.mysql.Delete<Topic>(new[] { 1, 2 }).AsTable(a => "TopicAsTable").ToSql(); | ||||
| 			Assert.Equal("DELETE FROM `TopicAsTable` WHERE (`Id` = 1 OR `Id` = 2)", sql); | ||||
|  | ||||
| 			sql = g.mysql.Delete<Topic>(new Topic { Id = 1, Title = "test" }).AsTable(a => "TopicAsTable").ToSql(); | ||||
| 			Assert.Equal("DELETE FROM `TopicAsTable` WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = g.mysql.Delete<Topic>(new[] { new Topic { Id = 1, Title = "test" }, new Topic { Id = 2, Title = "test" } }).AsTable(a => "TopicAsTable").ToSql(); | ||||
| 			Assert.Equal("DELETE FROM `TopicAsTable` WHERE (`Id` = 1 OR `Id` = 2)", sql); | ||||
|  | ||||
| 			sql = g.mysql.Delete<Topic>(new { id = 1 }).AsTable(a => "TopicAsTable").ToSql(); | ||||
| 			Assert.Equal("DELETE FROM `TopicAsTable` WHERE (`Id` = 1)", sql); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,135 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnector { | ||||
| 	public class MySqlInsertTest { | ||||
|  | ||||
| 		IInsert<Topic> insert => g.mysql.Insert<Topic>(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| 		[Table(Name = "tb_topic")] | ||||
| 		class Topic { | ||||
| 			[Column(IsIdentity = true, IsPrimary = true)] | ||||
| 			public int Id { get; set; } | ||||
| 			public int Clicks { get; set; } | ||||
| 			public string Title { get; set; } | ||||
| 			public DateTime CreateTime { get; set; } | ||||
| 		} | ||||
| 		class TestEnumInsertTb { | ||||
| 			[Column(IsIdentity = true)] | ||||
| 			public int id { get; set; } | ||||
| 			public TestEnumInserTbType type { get; set; } | ||||
| 			public DateTime time { get; set; } = new DateTime(); | ||||
| 		} | ||||
| 		enum TestEnumInserTbType { str1, biggit, sum211 } | ||||
|   | ||||
| 		[Fact] | ||||
| 		public void AppendData() { | ||||
| 			var items = new List<Topic>(); | ||||
| 			for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 }); | ||||
|  | ||||
| 			var sql = insert.AppendData(items.First()).ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `tb_topic`(`Clicks`, `Title`, `CreateTime`) VALUES(@Clicks_0, @Title_0, @CreateTime_0)", sql); | ||||
|  | ||||
| 			sql = insert.AppendData(items).ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `tb_topic`(`Clicks`, `Title`, `CreateTime`) VALUES(@Clicks_0, @Title_0, @CreateTime_0), (@Clicks_1, @Title_1, @CreateTime_1), (@Clicks_2, @Title_2, @CreateTime_2), (@Clicks_3, @Title_3, @CreateTime_3), (@Clicks_4, @Title_4, @CreateTime_4), (@Clicks_5, @Title_5, @CreateTime_5), (@Clicks_6, @Title_6, @CreateTime_6), (@Clicks_7, @Title_7, @CreateTime_7), (@Clicks_8, @Title_8, @CreateTime_8), (@Clicks_9, @Title_9, @CreateTime_9)", sql); | ||||
|  | ||||
| 			sql = insert.AppendData(items).InsertColumns(a => a.Title).ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `tb_topic`(`Title`) VALUES(@Title_0), (@Title_1), (@Title_2), (@Title_3), (@Title_4), (@Title_5), (@Title_6), (@Title_7), (@Title_8), (@Title_9)", sql); | ||||
|  | ||||
| 			sql = insert.AppendData(items).IgnoreColumns(a => a.CreateTime).ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `tb_topic`(`Clicks`, `Title`) VALUES(@Clicks_0, @Title_0), (@Clicks_1, @Title_1), (@Clicks_2, @Title_2), (@Clicks_3, @Title_3), (@Clicks_4, @Title_4), (@Clicks_5, @Title_5), (@Clicks_6, @Title_6), (@Clicks_7, @Title_7), (@Clicks_8, @Title_8), (@Clicks_9, @Title_9)", sql); | ||||
|  | ||||
| 			sql = g.mysql.Insert<TestEnumInsertTb>().AppendData(new TestEnumInsertTb { type = TestEnumInserTbType.sum211, time = DateTime.Now }).ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `TestEnumInsertTb`(`type`, `time`) VALUES(@type_0, @time_0)", sql); | ||||
|  | ||||
| 			sql = g.mysql.Insert<TestEnumInsertTb>().AppendData(new TestEnumInsertTb { type = TestEnumInserTbType.sum211 }).NoneParameter().ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `TestEnumInsertTb`(`type`, `time`) VALUES('sum211', '0001-01-01 00:00:00.000')", sql); | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void InsertColumns() { | ||||
| 			var items = new List<Topic>(); | ||||
| 			for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 }); | ||||
|  | ||||
| 			var sql = insert.AppendData(items).InsertColumns(a => a.Title).ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `tb_topic`(`Title`) VALUES(@Title_0), (@Title_1), (@Title_2), (@Title_3), (@Title_4), (@Title_5), (@Title_6), (@Title_7), (@Title_8), (@Title_9)", sql); | ||||
|  | ||||
| 			sql = insert.AppendData(items).InsertColumns(a =>new { a.Title, a.Clicks }).ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `tb_topic`(`Clicks`, `Title`) VALUES(@Clicks_0, @Title_0), (@Clicks_1, @Title_1), (@Clicks_2, @Title_2), (@Clicks_3, @Title_3), (@Clicks_4, @Title_4), (@Clicks_5, @Title_5), (@Clicks_6, @Title_6), (@Clicks_7, @Title_7), (@Clicks_8, @Title_8), (@Clicks_9, @Title_9)", sql); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void IgnoreColumns() { | ||||
| 			var items = new List<Topic>(); | ||||
| 			for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 }); | ||||
|  | ||||
| 			var sql = insert.AppendData(items).IgnoreColumns(a => a.CreateTime).ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `tb_topic`(`Clicks`, `Title`) VALUES(@Clicks_0, @Title_0), (@Clicks_1, @Title_1), (@Clicks_2, @Title_2), (@Clicks_3, @Title_3), (@Clicks_4, @Title_4), (@Clicks_5, @Title_5), (@Clicks_6, @Title_6), (@Clicks_7, @Title_7), (@Clicks_8, @Title_8), (@Clicks_9, @Title_9)", sql); | ||||
|  | ||||
| 			sql = insert.AppendData(items).IgnoreColumns(a => new { a.Title, a.CreateTime }).ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `tb_topic`(`Clicks`) VALUES(@Clicks_0), (@Clicks_1), (@Clicks_2), (@Clicks_3), (@Clicks_4), (@Clicks_5), (@Clicks_6), (@Clicks_7), (@Clicks_8), (@Clicks_9)", sql); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ExecuteAffrows() { | ||||
| 			var items = new List<Topic>(); | ||||
| 			for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now }); | ||||
|  | ||||
| 			Assert.Equal(1, insert.AppendData(items.First()).ExecuteAffrows()); | ||||
| 			Assert.Equal(10, insert.AppendData(items).ExecuteAffrows()); | ||||
|  | ||||
| 			Assert.Equal(1, g.mysql.Insert<TestEnumInsertTb>().AppendData(new TestEnumInsertTb { type = TestEnumInserTbType.sum211 }).ExecuteAffrows()); | ||||
| 			Assert.Equal(1, g.mysql.Insert<TestEnumInsertTb>().AppendData(new TestEnumInsertTb { type = TestEnumInserTbType.sum211 }).NoneParameter().ExecuteAffrows()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ExecuteIdentity() { | ||||
| 			var items = new List<Topic>(); | ||||
| 			for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 }); | ||||
|  | ||||
| 			Assert.NotEqual(0, insert.AppendData(items.First()).ExecuteIdentity()); | ||||
|  | ||||
| 			var id = g.mysql.Insert<TestEnumInsertTb>().AppendData(new TestEnumInsertTb { type = TestEnumInserTbType.sum211 }).ExecuteIdentity(); | ||||
| 			Assert.Equal(TestEnumInserTbType.sum211, g.mysql.Select< TestEnumInsertTb>().Where(a => a.id == id).First()?.type); | ||||
| 			id = g.mysql.Insert<TestEnumInsertTb>().AppendData(new TestEnumInsertTb { type = TestEnumInserTbType.sum211 }).NoneParameter().ExecuteIdentity(); | ||||
| 			Assert.Equal(TestEnumInserTbType.sum211, g.mysql.Select<TestEnumInsertTb>().Where(a => a.id == id).First()?.type); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ExecuteInserted() { | ||||
| 			var items = new List<Topic>(); | ||||
| 			for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 }); | ||||
|  | ||||
| 			//insert.AppendData(items.First()).ExecuteInserted(); | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void AsTable() { | ||||
| 			var items = new List<Topic>(); | ||||
| 			for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newTitle{a}", Clicks = a * 100 }); | ||||
|  | ||||
| 			var sql = insert.AppendData(items.First()).AsTable(a => "Topic_InsertAsTable").ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `Topic_InsertAsTable`(`Clicks`, `Title`, `CreateTime`) VALUES(@Clicks_0, @Title_0, @CreateTime_0)", sql); | ||||
|  | ||||
| 			sql = insert.AppendData(items).AsTable(a => "Topic_InsertAsTable").ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `Topic_InsertAsTable`(`Clicks`, `Title`, `CreateTime`) VALUES(@Clicks_0, @Title_0, @CreateTime_0), (@Clicks_1, @Title_1, @CreateTime_1), (@Clicks_2, @Title_2, @CreateTime_2), (@Clicks_3, @Title_3, @CreateTime_3), (@Clicks_4, @Title_4, @CreateTime_4), (@Clicks_5, @Title_5, @CreateTime_5), (@Clicks_6, @Title_6, @CreateTime_6), (@Clicks_7, @Title_7, @CreateTime_7), (@Clicks_8, @Title_8, @CreateTime_8), (@Clicks_9, @Title_9, @CreateTime_9)", sql); | ||||
|  | ||||
| 			sql = insert.AppendData(items).InsertColumns(a => a.Title).AsTable(a => "Topic_InsertAsTable").ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `Topic_InsertAsTable`(`Title`) VALUES(@Title_0), (@Title_1), (@Title_2), (@Title_3), (@Title_4), (@Title_5), (@Title_6), (@Title_7), (@Title_8), (@Title_9)", sql); | ||||
|  | ||||
| 			sql = insert.AppendData(items).IgnoreColumns(a => a.CreateTime).AsTable(a => "Topic_InsertAsTable").ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `Topic_InsertAsTable`(`Clicks`, `Title`) VALUES(@Clicks_0, @Title_0), (@Clicks_1, @Title_1), (@Clicks_2, @Title_2), (@Clicks_3, @Title_3), (@Clicks_4, @Title_4), (@Clicks_5, @Title_5), (@Clicks_6, @Title_6), (@Clicks_7, @Title_7), (@Clicks_8, @Title_8), (@Clicks_9, @Title_9)", sql); | ||||
|  | ||||
| 			sql = insert.AppendData(items).InsertColumns(a => a.Title).AsTable(a => "Topic_InsertAsTable").ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `Topic_InsertAsTable`(`Title`) VALUES(@Title_0), (@Title_1), (@Title_2), (@Title_3), (@Title_4), (@Title_5), (@Title_6), (@Title_7), (@Title_8), (@Title_9)", sql); | ||||
|  | ||||
| 			sql = insert.AppendData(items).InsertColumns(a => new { a.Title, a.Clicks }).AsTable(a => "Topic_InsertAsTable").ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `Topic_InsertAsTable`(`Clicks`, `Title`) VALUES(@Clicks_0, @Title_0), (@Clicks_1, @Title_1), (@Clicks_2, @Title_2), (@Clicks_3, @Title_3), (@Clicks_4, @Title_4), (@Clicks_5, @Title_5), (@Clicks_6, @Title_6), (@Clicks_7, @Title_7), (@Clicks_8, @Title_8), (@Clicks_9, @Title_9)", sql); | ||||
|  | ||||
| 			sql = insert.AppendData(items).IgnoreColumns(a => a.CreateTime).AsTable(a => "Topic_InsertAsTable").ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `Topic_InsertAsTable`(`Clicks`, `Title`) VALUES(@Clicks_0, @Title_0), (@Clicks_1, @Title_1), (@Clicks_2, @Title_2), (@Clicks_3, @Title_3), (@Clicks_4, @Title_4), (@Clicks_5, @Title_5), (@Clicks_6, @Title_6), (@Clicks_7, @Title_7), (@Clicks_8, @Title_8), (@Clicks_9, @Title_9)", sql); | ||||
|  | ||||
| 			sql = insert.AppendData(items).IgnoreColumns(a => new { a.Title, a.CreateTime }).AsTable(a => "Topic_InsertAsTable").ToSql(); | ||||
| 			Assert.Equal("INSERT INTO `Topic_InsertAsTable`(`Clicks`) VALUES(@Clicks_0), (@Clicks_1), (@Clicks_2), (@Clicks_3), (@Clicks_4), (@Clicks_5), (@Clicks_6), (@Clicks_7), (@Clicks_8), (@Clicks_9)", sql); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -0,0 +1,186 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnector { | ||||
| 	public class MySqlUpdateTest { | ||||
| 		IUpdate<Topic> update => g.mysql.Update<Topic>(); | ||||
|  | ||||
| 		[Table(Name = "tb_topic")] | ||||
| 		class Topic { | ||||
| 			[Column(IsIdentity = true, IsPrimary = true)] | ||||
| 			public int Id { get; set; } | ||||
| 			public int? Clicks { get; set; } | ||||
| 			public string Title { get; set; } | ||||
| 			public DateTime CreateTime { get; set; } | ||||
| 		} | ||||
| 		class TestEnumUpdateTb { | ||||
| 			[Column(IsIdentity = true)] | ||||
| 			public int id { get; set; } | ||||
| 			public TestEnumUpdateTbType type { get; set; } | ||||
| 			public DateTime time { get; set; } = new DateTime(); | ||||
| 		} | ||||
| 		enum TestEnumUpdateTbType { str1, biggit, sum211 } | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void Dywhere() { | ||||
| 			Assert.Null(g.mysql.Update<Topic>().ToSql()); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET title='test' \r\nWHERE (`Id` = 1 OR `Id` = 2)", g.mysql.Update<Topic>(new[] { 1, 2 }).SetRaw("title='test'").ToSql()); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET title='test1' \r\nWHERE (`Id` = 1)", g.mysql.Update<Topic>(new Topic { Id = 1, Title = "test" }).SetRaw("title='test1'").ToSql()); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET title='test1' \r\nWHERE (`Id` = 1 OR `Id` = 2)", g.mysql.Update<Topic>(new[] { new Topic { Id = 1, Title = "test" }, new Topic { Id = 2, Title = "test" } }).SetRaw("title='test1'").ToSql()); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET title='test1' \r\nWHERE (`Id` = 1)", g.mysql.Update<Topic>(new { id = 1 }).SetRaw("title='test1'").ToSql()); | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void SetSource() { | ||||
| 			var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `Clicks` = @p_0, `Title` = @p_1, `CreateTime` = @p_2 WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			var items = new List<Topic>(); | ||||
| 			for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 }); | ||||
|  | ||||
| 			sql = update.SetSource(items).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `Clicks` = CASE `Id` WHEN 1 THEN @p_0 WHEN 2 THEN @p_1 WHEN 3 THEN @p_2 WHEN 4 THEN @p_3 WHEN 5 THEN @p_4 WHEN 6 THEN @p_5 WHEN 7 THEN @p_6 WHEN 8 THEN @p_7 WHEN 9 THEN @p_8 WHEN 10 THEN @p_9 END, `Title` = CASE `Id` WHEN 1 THEN @p_10 WHEN 2 THEN @p_11 WHEN 3 THEN @p_12 WHEN 4 THEN @p_13 WHEN 5 THEN @p_14 WHEN 6 THEN @p_15 WHEN 7 THEN @p_16 WHEN 8 THEN @p_17 WHEN 9 THEN @p_18 WHEN 10 THEN @p_19 END, `CreateTime` = CASE `Id` WHEN 1 THEN @p_20 WHEN 2 THEN @p_21 WHEN 3 THEN @p_22 WHEN 4 THEN @p_23 WHEN 5 THEN @p_24 WHEN 6 THEN @p_25 WHEN 7 THEN @p_26 WHEN 8 THEN @p_27 WHEN 9 THEN @p_28 WHEN 10 THEN @p_29 END WHERE (`Id` IN (1,2,3,4,5,6,7,8,9,10))", sql); | ||||
|  | ||||
| 			sql = update.SetSource(items).IgnoreColumns(a => new { a.Clicks, a.CreateTime }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `Title` = CASE `Id` WHEN 1 THEN @p_0 WHEN 2 THEN @p_1 WHEN 3 THEN @p_2 WHEN 4 THEN @p_3 WHEN 5 THEN @p_4 WHEN 6 THEN @p_5 WHEN 7 THEN @p_6 WHEN 8 THEN @p_7 WHEN 9 THEN @p_8 WHEN 10 THEN @p_9 END WHERE (`Id` IN (1,2,3,4,5,6,7,8,9,10))", sql); | ||||
|  | ||||
| 			sql = update.SetSource(items).Set(a => a.CreateTime, new DateTime(2020,1,1)).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `CreateTime` = @p_0 WHERE (`Id` IN (1,2,3,4,5,6,7,8,9,10))", sql); | ||||
|  | ||||
| 			sql = g.mysql.Insert<TestEnumUpdateTb>().AppendData(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("INSERT INTO `TestEnumUpdateTb`(`type`, `time`) VALUES(@type_0, @time_0)", sql); | ||||
| 			var id = g.mysql.Insert<TestEnumUpdateTb>().AppendData(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).ExecuteIdentity(); | ||||
| 			Assert.True(id > 0); | ||||
| 			Assert.Equal(TestEnumUpdateTbType.sum211, g.mysql.Select<TestEnumUpdateTb>().Where(a => a.id == id).First()?.type); | ||||
|  | ||||
| 			sql = g.mysql.Update<TestEnumUpdateTb>().SetSource(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `TestEnumUpdateTb` SET `type` = @p_0, `time` = @p_1 WHERE (`id` = 0)", sql); | ||||
| 			g.mysql.Update<TestEnumUpdateTb>().SetSource(new TestEnumUpdateTb { id = (int)id, type = TestEnumUpdateTbType.biggit }).ExecuteAffrows(); | ||||
| 			Assert.Equal(TestEnumUpdateTbType.biggit, g.mysql.Select<TestEnumUpdateTb>().Where(a => a.id == id).First()?.type); | ||||
|  | ||||
| 			sql = g.mysql.Insert<TestEnumUpdateTb>().NoneParameter().AppendData(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("INSERT INTO `TestEnumUpdateTb`(`type`, `time`) VALUES('sum211', '0001-01-01 00:00:00.000')", sql); | ||||
| 			id = g.mysql.Insert<TestEnumUpdateTb>().NoneParameter().AppendData(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).ExecuteIdentity(); | ||||
| 			Assert.True(id > 0); | ||||
| 			Assert.Equal(TestEnumUpdateTbType.sum211, g.mysql.Select<TestEnumUpdateTb>().Where(a => a.id == id).First()?.type); | ||||
|  | ||||
| 			sql = g.mysql.Update<TestEnumUpdateTb>().NoneParameter().SetSource(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `TestEnumUpdateTb` SET `type` = 'sum211', `time` = '0001-01-01 00:00:00.000' WHERE (`id` = 0)", sql); | ||||
| 			g.mysql.Update<TestEnumUpdateTb>().NoneParameter().SetSource(new TestEnumUpdateTb { id = (int)id, type = TestEnumUpdateTbType.biggit }).ExecuteAffrows(); | ||||
| 			Assert.Equal(TestEnumUpdateTbType.biggit, g.mysql.Select<TestEnumUpdateTb>().Where(a => a.id == id).First()?.type); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void IgnoreColumns() { | ||||
| 			var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).IgnoreColumns(a => new { a.Clicks, a.CreateTime }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `Title` = @p_0 WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = g.mysql.Update<TestEnumUpdateTb>().SetSource(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).IgnoreColumns(a => a.time).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `TestEnumUpdateTb` SET `type` = @p_0 WHERE (`id` = 0)", sql); | ||||
|  | ||||
| 			sql = g.mysql.Update<TestEnumUpdateTb>().NoneParameter().SetSource(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).IgnoreColumns(a => a.time).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `TestEnumUpdateTb` SET `type` = 'sum211' WHERE (`id` = 0)", sql); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void UpdateColumns() { | ||||
| 			var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).UpdateColumns(a => a.Title).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `Title` = @p_0 WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = g.mysql.Update<TestEnumUpdateTb>().SetSource(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).UpdateColumns(a => a.type).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `TestEnumUpdateTb` SET `type` = @p_0 WHERE (`id` = 0)", sql); | ||||
|  | ||||
| 			sql = g.mysql.Update<TestEnumUpdateTb>().NoneParameter().SetSource(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).UpdateColumns(a => a.type).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `TestEnumUpdateTb` SET `type` = 'sum211' WHERE (`id` = 0)", sql); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Set() { | ||||
| 			var sql = update.Where(a => a.Id == 1).Set(a => a.Title, "newtitle").ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `Title` = @p_0 WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = update.Where(a => a.Id == 1).Set(a => a.Title, "newtitle").Set(a => a.CreateTime, new DateTime(2020, 1, 1)).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `Title` = @p_0, `CreateTime` = @p_1 WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = update.Set(a => a.Clicks * 10 / 1).Where(a => a.Id == 1).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `Clicks` = ifnull(`Clicks`, 0) * 10 / 1 WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = update.Set(a => a.Id - 10).Where(a => a.Id == 1).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `Id` = (`Id` - 10) WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			int incrv = 10; | ||||
| 			sql = update.Set(a => a.Clicks * incrv / 1).Where(a => a.Id == 1).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `Clicks` = ifnull(`Clicks`, 0) * 10 / 1 WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = update.Set(a => a.Id - incrv).Where(a => a.Id == 1).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `Id` = (`Id` - 10) WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = update.Set(a => a.Clicks == a.Clicks * 10 / 1).Where(a => a.Id == 1).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `Clicks` = `Clicks` * 10 / 1 WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = update.Set(a => a.Id == 10).Where(a => a.Id == 1).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET `Id` = 10 WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			var id = g.mysql.Insert<TestEnumUpdateTb>().AppendData(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).ExecuteIdentity(); | ||||
| 			Assert.True(id > 0); | ||||
| 			sql = g.mysql.Update<TestEnumUpdateTb>().Where(a => a.id == id).Set(a => a.type, TestEnumUpdateTbType.biggit).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal($"UPDATE `TestEnumUpdateTb` SET `type` = @p_0 WHERE (`id` = {id})", sql); | ||||
| 			g.mysql.Update<TestEnumUpdateTb>().Where(a => a.id == id).Set(a => a.type, TestEnumUpdateTbType.biggit).ExecuteAffrows(); | ||||
| 			Assert.Equal(TestEnumUpdateTbType.biggit, g.mysql.Select<TestEnumUpdateTb>().Where(a => a.id == id).First()?.type); | ||||
|  | ||||
| 			sql = g.mysql.Update<TestEnumUpdateTb>().NoneParameter().Where(a => a.id == id).Set(a => a.type, TestEnumUpdateTbType.str1).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal($"UPDATE `TestEnumUpdateTb` SET `type` = 'str1' WHERE (`id` = {id})", sql); | ||||
| 			g.mysql.Update<TestEnumUpdateTb>().NoneParameter().Where(a => a.id == id).Set(a => a.type, TestEnumUpdateTbType.str1).ExecuteAffrows(); | ||||
| 			Assert.Equal(TestEnumUpdateTbType.str1, g.mysql.Select<TestEnumUpdateTb>().Where(a => a.id == id).First()?.type); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void SetRaw() { | ||||
| 			var sql = update.Where(a => a.Id == 1).SetRaw("clicks = clicks + @incrClick", new { incrClick = 1 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET clicks = clicks + @incrClick WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = g.mysql.Update<TestEnumUpdateTb>().NoneParameter().Where(a => a.id == 0).SetRaw("`type` = {0}".FormatMySql(TestEnumUpdateTbType.sum211)).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `TestEnumUpdateTb` SET `type` = 'sum211' WHERE (`id` = 0)", sql); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Where() { | ||||
| 			var sql = update.Where(a => a.Id == 1).SetRaw("title='newtitle'").ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET title='newtitle' WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = update.Where("id = @id", new { id = 1 }).SetRaw("title='newtitle'").ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET title='newtitle' WHERE (id = @id)", sql); | ||||
|  | ||||
| 			var item = new Topic { Id = 1, Title = "newtitle" }; | ||||
| 			sql = update.Where(item).SetRaw("title='newtitle'").ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET title='newtitle' WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			var items = new List<Topic>(); | ||||
| 			for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 }); | ||||
| 			sql = update.Where(items).SetRaw("title='newtitle'").ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `tb_topic` SET title='newtitle' WHERE (`Id` IN (1,2,3,4,5,6,7,8,9,10))", sql); | ||||
|  | ||||
| 			sql = g.mysql.Update<TestEnumUpdateTb>().NoneParameter().Where(a => a.id == 0 && a.type == TestEnumUpdateTbType.str1) | ||||
| 				.Set(a => a.type, TestEnumUpdateTbType.sum211).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("UPDATE `TestEnumUpdateTb` SET `type` = 'sum211' WHERE (`id` = 0 AND `type` = 'str1')", sql); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void WhereExists() { | ||||
|  | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ExecuteAffrows() { | ||||
|  | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ExecuteUpdated() { | ||||
|  | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void AsTable() { | ||||
| 			Assert.Null(g.mysql.Update<Topic>().ToSql()); | ||||
| 			Assert.Equal("UPDATE `tb_topicAsTable` SET title='test' \r\nWHERE (`Id` = 1 OR `Id` = 2)", g.mysql.Update<Topic>(new[] { 1, 2 }).SetRaw("title='test'").AsTable(a => "tb_topicAsTable").ToSql()); | ||||
| 			Assert.Equal("UPDATE `tb_topicAsTable` SET title='test1' \r\nWHERE (`Id` = 1)", g.mysql.Update<Topic>(new Topic { Id = 1, Title = "test" }).SetRaw("title='test1'").AsTable(a => "tb_topicAsTable").ToSql()); | ||||
| 			Assert.Equal("UPDATE `tb_topicAsTable` SET title='test1' \r\nWHERE (`Id` = 1 OR `Id` = 2)", g.mysql.Update<Topic>(new[] { new Topic { Id = 1, Title = "test" }, new Topic { Id = 2, Title = "test" } }).SetRaw("title='test1'").AsTable(a => "tb_topicAsTable").ToSql()); | ||||
| 			Assert.Equal("UPDATE `tb_topicAsTable` SET title='test1' \r\nWHERE (`Id` = 1)", g.mysql.Update<Topic>(new { id = 1 }).SetRaw("title='test1'").AsTable(a => "tb_topicAsTable").ToSql()); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -0,0 +1,254 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using System; | ||||
| using System.Numerics; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnectorMapType { | ||||
| 	public class EnumTest { | ||||
| 		class EnumTestMap { | ||||
| 			public Guid id { get; set; } | ||||
|  | ||||
| 			[Column(MapType = typeof(string))] | ||||
| 			public ToStringMapEnum enum_to_string { get; set; } | ||||
| 			[Column(MapType = typeof(string))] | ||||
| 			public ToStringMapEnum? enumnullable_to_string { get; set; } | ||||
|  | ||||
| 			[Column(MapType = typeof(int))] | ||||
| 			public ToStringMapEnum enum_to_int { get; set; } | ||||
| 			[Column(MapType = typeof(int?))] | ||||
| 			public ToStringMapEnum? enumnullable_to_int { get; set; } | ||||
| 		} | ||||
| 		public enum ToStringMapEnum { <EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>, abc, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> } | ||||
| 		[Fact] | ||||
| 		public void EnumToString() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new EnumTestMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enum_to_string, find.enum_to_string); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>, find.enum_to_string); | ||||
|  | ||||
| 			item = new EnumTestMap { enum_to_string = ToStringMapEnum.abc }; | ||||
| 			Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.abc).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enum_to_string, find.enum_to_string); | ||||
| 			Assert.Equal(ToStringMapEnum.abc, find.enum_to_string); | ||||
|  | ||||
| 			//update all | ||||
| 			item.enum_to_string = ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>; | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enum_to_string, find.enum_to_string); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, find.enum_to_string); | ||||
|  | ||||
| 			item.enum_to_string = ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>; | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enum_to_string, find.enum_to_string); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>, find.enum_to_string); | ||||
|  | ||||
| 			//update set | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enum_to_string, ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, find.enum_to_string); | ||||
|  | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enum_to_string, ToStringMapEnum.abc).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.abc).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(ToStringMapEnum.abc, find.enum_to_string); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			Assert.Equal(1, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.abc).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void EnumNullableToString() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new EnumTestMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string); | ||||
| 			Assert.Null(find.enumnullable_to_string); | ||||
|  | ||||
| 			item = new EnumTestMap { enumnullable_to_string = ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD> }; | ||||
| 			Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>, find.enumnullable_to_string); | ||||
|  | ||||
| 			//update all | ||||
| 			item.enumnullable_to_string = ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>; | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, find.enumnullable_to_string); | ||||
|  | ||||
| 			item.enumnullable_to_string = null; | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string); | ||||
| 			Assert.Null(find.enumnullable_to_string); | ||||
|  | ||||
| 			//update set | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, ToStringMapEnum.abc).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(ToStringMapEnum.abc, find.enumnullable_to_string); | ||||
|  | ||||
|  | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, null).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Null(find.enumnullable_to_string); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			Assert.Equal(1, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void EnumToInt() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new EnumTestMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enum_to_int, find.enum_to_int); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>, find.enum_to_int); | ||||
|  | ||||
| 			item = new EnumTestMap { enum_to_int = ToStringMapEnum.abc }; | ||||
| 			Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.abc).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enum_to_int, find.enum_to_int); | ||||
| 			Assert.Equal(ToStringMapEnum.abc, find.enum_to_int); | ||||
|  | ||||
| 			//update all | ||||
| 			item.enum_to_int = ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>; | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enum_to_int, find.enum_to_int); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, find.enum_to_int); | ||||
|  | ||||
| 			item.enum_to_int = ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>; | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enum_to_int, find.enum_to_int); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>, find.enum_to_int); | ||||
|  | ||||
| 			//update set | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enum_to_int, ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, find.enum_to_int); | ||||
|  | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enum_to_int, ToStringMapEnum.abc).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.abc).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(ToStringMapEnum.abc, find.enum_to_int); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			Assert.Equal(1, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.abc).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void EnumNullableToInt() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new EnumTestMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enumnullable_to_int, find.enumnullable_to_int); | ||||
| 			Assert.Null(find.enumnullable_to_int); | ||||
|  | ||||
| 			item = new EnumTestMap { enumnullable_to_int = ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD> }; | ||||
| 			Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enumnullable_to_int, find.enumnullable_to_int); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>, find.enumnullable_to_int); | ||||
|  | ||||
| 			//update all | ||||
| 			item.enumnullable_to_int = ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>; | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enumnullable_to_int, find.enumnullable_to_int); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, find.enumnullable_to_int); | ||||
|  | ||||
| 			item.enumnullable_to_int = null; | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enumnullable_to_int, find.enumnullable_to_int); | ||||
| 			Assert.Null(find.enumnullable_to_int); | ||||
|  | ||||
| 			//update set | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_int, ToStringMapEnum.abc).ExecuteAffrows()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.abc).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(ToStringMapEnum.abc, find.enumnullable_to_int); | ||||
|  | ||||
|  | ||||
| 			Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_int, null).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.abc).First()); | ||||
| 			find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Null(find.enumnullable_to_int); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			Assert.Equal(1, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == null).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,557 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using System; | ||||
| using System.Numerics; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnectorMapType { | ||||
| 	public class ToStringTest { | ||||
| 		class ToStringMap { | ||||
| 			public Guid id { get; set; } | ||||
|  | ||||
| 			[Column(MapType = typeof(string))] | ||||
| 			public TimeSpan timespan_to_string { get; set; } | ||||
| 			[Column(MapType = typeof(string))] | ||||
| 			public TimeSpan? timespannullable_to_string { get; set; } | ||||
|  | ||||
| 			[Column(MapType = typeof(string))] | ||||
| 			public DateTime datetime_to_string { get; set; } | ||||
| 			[Column(MapType = typeof(string))] | ||||
| 			public DateTime? datetimenullable_to_string { get; set; } | ||||
|  | ||||
| 			[Column(MapType = typeof(string))] | ||||
| 			public Guid guid_to_string { get; set; } | ||||
| 			[Column(MapType = typeof(string))] | ||||
| 			public Guid? guidnullable_to_string { get; set; } | ||||
|  | ||||
| 			[Column(MapType = typeof(string))] | ||||
| 			public ToStringMapEnum enum_to_string { get; set; } | ||||
| 			[Column(MapType = typeof(string))] | ||||
| 			public ToStringMapEnum? enumnullable_to_string { get; set; } | ||||
|  | ||||
| 			[Column(MapType = typeof(string))] | ||||
| 			public BigInteger biginteger_to_string { get; set; } | ||||
| 			[Column(MapType = typeof(string))] | ||||
| 			public BigInteger? bigintegernullable_to_string { get; set; } | ||||
| 		} | ||||
| 		public enum ToStringMapEnum { <EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>, abc, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> } | ||||
| 		[Fact] | ||||
| 		public void Enum1() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new ToStringMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enum_to_string, find.enum_to_string); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>, find.enum_to_string); | ||||
|  | ||||
| 			item = new ToStringMap { enum_to_string = ToStringMapEnum.abc }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.abc).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enum_to_string, find.enum_to_string); | ||||
| 			Assert.Equal(ToStringMapEnum.abc, find.enum_to_string); | ||||
|  | ||||
| 			//update all | ||||
| 			item.enum_to_string = ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>; | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enum_to_string, find.enum_to_string); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, find.enum_to_string); | ||||
|  | ||||
| 			item.enum_to_string = ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>; | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enum_to_string, find.enum_to_string); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>, find.enum_to_string); | ||||
|  | ||||
| 			//update set | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.enum_to_string, ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, find.enum_to_string); | ||||
|  | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.enum_to_string, ToStringMapEnum.abc).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.abc).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(ToStringMapEnum.abc, find.enum_to_string); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.abc).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void EnumNullable() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new ToStringMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string); | ||||
| 			Assert.Null(find.enumnullable_to_string); | ||||
|  | ||||
| 			item = new ToStringMap { enumnullable_to_string = ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD> }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>, find.enumnullable_to_string); | ||||
|  | ||||
| 			//update all | ||||
| 			item.enumnullable_to_string = ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>; | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string); | ||||
| 			Assert.Equal(ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, find.enumnullable_to_string); | ||||
|  | ||||
| 			item.enumnullable_to_string = null; | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string); | ||||
| 			Assert.Null(find.enumnullable_to_string); | ||||
|  | ||||
| 			//update set | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, ToStringMapEnum.abc).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(ToStringMapEnum.abc, find.enumnullable_to_string); | ||||
|  | ||||
|  | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, null).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Null(find.enumnullable_to_string); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows()); | ||||
| 			Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void BigInteger1() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new ToStringMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 0).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.biginteger_to_string, find.biginteger_to_string); | ||||
| 			Assert.Equal(0, find.biginteger_to_string); | ||||
|  | ||||
| 			item = new ToStringMap { biginteger_to_string = 100 }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 100).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.biginteger_to_string, find.biginteger_to_string); | ||||
| 			Assert.Equal(100, find.biginteger_to_string); | ||||
|  | ||||
| 			//update all | ||||
| 			item.biginteger_to_string = 200; | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 200).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.biginteger_to_string, find.biginteger_to_string); | ||||
| 			Assert.Equal(200, find.biginteger_to_string); | ||||
|  | ||||
| 			item.biginteger_to_string = 205; | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 205).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.biginteger_to_string, find.biginteger_to_string); | ||||
| 			Assert.Equal(205, find.biginteger_to_string); | ||||
|  | ||||
| 			//update set | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.biginteger_to_string, 522).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 522).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(522, find.biginteger_to_string); | ||||
|  | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.biginteger_to_string, 10005).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 10005).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(10005, find.biginteger_to_string); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 522).ExecuteAffrows()); | ||||
| 			Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 205).ExecuteAffrows()); | ||||
| 			Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 10005).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void BigIntegerNullable() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new ToStringMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string); | ||||
| 			Assert.Null(find.bigintegernullable_to_string); | ||||
|  | ||||
| 			item = new ToStringMap { bigintegernullable_to_string = 101 }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 101).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string); | ||||
| 			Assert.Equal(101, find.bigintegernullable_to_string); | ||||
|  | ||||
| 			//update all | ||||
| 			item.bigintegernullable_to_string = 2004; | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 2004).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string); | ||||
| 			Assert.Equal(2004, find.bigintegernullable_to_string); | ||||
|  | ||||
| 			item.bigintegernullable_to_string = null; | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 2004).First()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string); | ||||
| 			Assert.Null(find.bigintegernullable_to_string); | ||||
|  | ||||
| 			//update set | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.bigintegernullable_to_string, 998).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 998).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(998, find.bigintegernullable_to_string); | ||||
|  | ||||
|  | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.bigintegernullable_to_string, null).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 998).First()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Null(find.bigintegernullable_to_string); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 998).ExecuteAffrows()); | ||||
| 			Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 2004).ExecuteAffrows()); | ||||
| 			Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == null).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TimeSpan1() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new ToStringMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.timespan_to_string, find.timespan_to_string); | ||||
| 			Assert.Equal(TimeSpan.Zero, find.timespan_to_string); | ||||
|  | ||||
| 			item = new ToStringMap { timespan_to_string = TimeSpan.FromDays(1) }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.timespan_to_string, find.timespan_to_string); | ||||
| 			Assert.Equal(TimeSpan.FromDays(1), find.timespan_to_string); | ||||
|  | ||||
| 			//update all | ||||
| 			item.timespan_to_string = TimeSpan.FromHours(10); | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.timespan_to_string, find.timespan_to_string); | ||||
| 			Assert.Equal(TimeSpan.FromHours(10), find.timespan_to_string); | ||||
|  | ||||
| 			//update set | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.timespan_to_string, TimeSpan.FromHours(11)).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(TimeSpan.FromHours(11), find.timespan_to_string); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TimeSpanNullable() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new ToStringMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.timespannullable_to_string, find.timespannullable_to_string); | ||||
| 			Assert.Null(find.timespannullable_to_string); | ||||
|  | ||||
| 			item = new ToStringMap { timespannullable_to_string = TimeSpan.FromDays(1) }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.timespannullable_to_string, find.timespannullable_to_string); | ||||
| 			Assert.Equal(TimeSpan.FromDays(1), find.timespannullable_to_string); | ||||
|  | ||||
| 			//update all | ||||
| 			item.timespannullable_to_string = TimeSpan.FromHours(10); | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.timespannullable_to_string, find.timespannullable_to_string); | ||||
| 			Assert.Equal(TimeSpan.FromHours(10), find.timespannullable_to_string); | ||||
|  | ||||
| 			item.timespannullable_to_string = null; | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.timespannullable_to_string, find.timespannullable_to_string); | ||||
| 			Assert.Null(find.timespannullable_to_string); | ||||
|  | ||||
| 			//update set | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.timespannullable_to_string, TimeSpan.FromHours(11)).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(TimeSpan.FromHours(11), find.timespannullable_to_string); | ||||
|  | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.timespannullable_to_string, null).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Null(find.timespannullable_to_string); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void DateTime1() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new ToStringMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.datetime_to_string, find.datetime_to_string); | ||||
| 			Assert.Equal(DateTime.MinValue, find.datetime_to_string); | ||||
|  | ||||
| 			item = new ToStringMap { datetime_to_string = DateTime.Parse("2000-1-1") }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.datetime_to_string, find.datetime_to_string); | ||||
| 			Assert.Equal(DateTime.Parse("2000-1-1"), find.datetime_to_string); | ||||
|  | ||||
| 			//update all | ||||
| 			item.datetime_to_string = DateTime.Parse("2000-1-11"); | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.datetime_to_string, find.datetime_to_string); | ||||
| 			Assert.Equal(DateTime.Parse("2000-1-11"), find.datetime_to_string); | ||||
|  | ||||
| 			//update set | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.datetime_to_string, DateTime.Parse("2000-1-12")).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(DateTime.Parse("2000-1-12"), find.datetime_to_string); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void DateTimeNullable() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new ToStringMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.datetimenullable_to_string, find.datetimenullable_to_string); | ||||
| 			Assert.Null(find.datetimenullable_to_string); | ||||
|  | ||||
| 			item = new ToStringMap { datetimenullable_to_string = DateTime.Parse("2000-1-1") }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.datetimenullable_to_string, find.datetimenullable_to_string); | ||||
| 			Assert.Equal(DateTime.Parse("2000-1-1"), find.datetimenullable_to_string); | ||||
|  | ||||
| 			//update all | ||||
| 			item.datetimenullable_to_string = DateTime.Parse("2000-1-11"); | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.datetimenullable_to_string, find.datetimenullable_to_string); | ||||
| 			Assert.Equal(DateTime.Parse("2000-1-11"), find.datetimenullable_to_string); | ||||
|  | ||||
| 			item.datetimenullable_to_string = null; | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.datetimenullable_to_string, find.datetimenullable_to_string); | ||||
| 			Assert.Null(find.datetimenullable_to_string); | ||||
|  | ||||
| 			//update set | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.datetimenullable_to_string, DateTime.Parse("2000-1-12")).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(DateTime.Parse("2000-1-12"), find.datetimenullable_to_string); | ||||
|  | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.datetimenullable_to_string, null).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Null(find.datetimenullable_to_string); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void Guid1() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new ToStringMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guid_to_string == Guid.Empty).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.guid_to_string, find.guid_to_string); | ||||
| 			Assert.Equal(Guid.Empty, find.guid_to_string); | ||||
|  | ||||
| 			var newid = Guid.NewGuid(); | ||||
| 			item = new ToStringMap { guid_to_string = newid }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guid_to_string == newid).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.guid_to_string, find.guid_to_string); | ||||
| 			Assert.Equal(newid, find.guid_to_string); | ||||
|  | ||||
| 			//update all | ||||
| 			newid = Guid.NewGuid(); | ||||
| 			item.guid_to_string = newid; | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guid_to_string == newid).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.guid_to_string, find.guid_to_string); | ||||
| 			Assert.Equal(newid, find.guid_to_string); | ||||
|  | ||||
| 			//update set | ||||
| 			newid = Guid.NewGuid(); | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.guid_to_string, newid).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guid_to_string == newid).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(newid, find.guid_to_string); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.guid_to_string == newid).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void GuidNullable() { | ||||
| 			//insert | ||||
| 			var orm = g.mysql; | ||||
| 			var item = new ToStringMap { }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string); | ||||
| 			Assert.Null(find.guidnullable_to_string); | ||||
|  | ||||
| 			var newid = Guid.NewGuid(); | ||||
| 			item = new ToStringMap { guidnullable_to_string = newid }; | ||||
| 			Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == newid).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string); | ||||
| 			Assert.Equal(newid, find.guidnullable_to_string); | ||||
|  | ||||
| 			//update all | ||||
| 			newid = Guid.NewGuid(); | ||||
| 			item.guidnullable_to_string = newid; | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == newid).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string); | ||||
| 			Assert.Equal(newid, find.guidnullable_to_string); | ||||
|  | ||||
| 			item.guidnullable_to_string = null; | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string); | ||||
| 			Assert.Null(find.guidnullable_to_string); | ||||
|  | ||||
| 			//update set | ||||
| 			newid = Guid.NewGuid(); | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.guidnullable_to_string, newid).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == newid).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Equal(newid, find.guidnullable_to_string); | ||||
|  | ||||
| 			Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.guidnullable_to_string, null).ExecuteAffrows()); | ||||
| 			find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == null).First(); | ||||
| 			Assert.NotNull(find); | ||||
| 			Assert.Equal(item.id, find.id); | ||||
| 			Assert.Null(find.guidnullable_to_string); | ||||
|  | ||||
| 			//delete | ||||
| 			Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == null).ExecuteAffrows()); | ||||
| 			Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First()); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,477 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using Newtonsoft.Json; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnector { | ||||
| 	public class MySqlCodeFirstTest { | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void <EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>_<EFBFBD>ֶ<EFBFBD>() { | ||||
| 			var sql = g.mysql.CodeFirst.GetComparisonDDLStatements<<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>2>(); | ||||
| 			g.mysql.CodeFirst.SyncStructure<<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>2>(); | ||||
|  | ||||
| 			var item = new <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>2 { | ||||
| 				<EFBFBD><EFBFBD><EFBFBD><EFBFBD> = "<22><><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>", | ||||
| 				<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD> = DateTime.Now | ||||
| 			}; | ||||
| 			Assert.Equal(1, g.mysql.Insert<<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>2>().AppendData(item).ExecuteAffrows()); | ||||
| 			Assert.NotEqual(Guid.Empty, item.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>); | ||||
| 			var item2 = g.mysql.Select<<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>2>().Where(a => a.<EFBFBD><EFBFBD><EFBFBD><EFBFBD> == item.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First(); | ||||
| 			Assert.NotNull(item2); | ||||
| 			Assert.Equal(item.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, item2.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>); | ||||
| 			Assert.Equal(item.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, item2.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>); | ||||
| 		} | ||||
| 		class <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>2 { | ||||
| 			[Column(IsPrimary = true)] | ||||
| 			public Guid <EFBFBD><EFBFBD><EFBFBD><EFBFBD> { get; set; } | ||||
|  | ||||
| 			public string <EFBFBD><EFBFBD><EFBFBD><EFBFBD> { get; set; } | ||||
|  | ||||
| 			public DateTime <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD> { get; set; } | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void AddUniques() { | ||||
| 			var sql = g.mysql.CodeFirst.GetComparisonDDLStatements<AddUniquesInfo>(); | ||||
| 			g.mysql.CodeFirst.SyncStructure<AddUniquesInfo>(); | ||||
| 		} | ||||
| 		[Table(Name = "AddUniquesInfo", OldName = "AddUniquesInfo2")] | ||||
| 		class AddUniquesInfo { | ||||
| 			public Guid id { get; set; } | ||||
| 			[Column(Unique = "uk_phone")] | ||||
| 			public string phone { get; set; } | ||||
|  | ||||
| 			[Column(Unique = "uk_group_index, uk_group_index22")] | ||||
| 			public string group { get; set; } | ||||
| 			[Column(Unique = "uk_group_index")] | ||||
| 			public int index { get; set; } | ||||
| 			[Column(Unique = "uk_group_index22")] | ||||
| 			public string index22 { get; set; } | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void AddField() { | ||||
| 			var sql = g.mysql.CodeFirst.GetComparisonDDLStatements<TopicAddField>(); | ||||
|  | ||||
| 			var id = g.mysql.Insert<TopicAddField>().AppendData(new TopicAddField { }).ExecuteIdentity(); | ||||
| 		} | ||||
|  | ||||
| 		[Table(Name = "TopicAddField", OldName = "xxxtb.TopicAddField")] | ||||
| 		public class TopicAddField { | ||||
| 			[Column(IsIdentity = true)] | ||||
| 			public int? Id { get; set; } | ||||
|  | ||||
| 			public string name { get; set; } | ||||
|  | ||||
| 			[Column(DbType = "varchar(200) not null", OldName = "title")] | ||||
| 			public string title222 { get; set; } = "10"; | ||||
|  | ||||
| 			[Column(IsIgnore = true)] | ||||
| 			public DateTime ct { get; set; } = DateTime.Now; | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void GetComparisonDDLStatements() { | ||||
|  | ||||
| 			var sql = g.mysql.CodeFirst.GetComparisonDDLStatements<TableAllType>(); | ||||
| 			if (string.IsNullOrEmpty(sql) == false) { | ||||
| 				Assert.Equal(@"CREATE TABLE IF NOT EXISTS `cccddd`.`tb_alltype` (  | ||||
|   `Id` INT(11) NOT NULL AUTO_INCREMENT,  | ||||
|   `testFieldBool` BIT(1) NOT NULL,  | ||||
|   `testFieldSByte` TINYINT(3) NOT NULL,  | ||||
|   `testFieldShort` SMALLINT(6) NOT NULL,  | ||||
|   `testFieldInt` INT(11) NOT NULL,  | ||||
|   `testFieldLong` BIGINT(20) NOT NULL,  | ||||
|   `testFieldByte` TINYINT(3) UNSIGNED NOT NULL,  | ||||
|   `testFieldUShort` SMALLINT(5) UNSIGNED NOT NULL,  | ||||
|   `testFieldUInt` INT(10) UNSIGNED NOT NULL,  | ||||
|   `testFieldULong` BIGINT(20) UNSIGNED NOT NULL,  | ||||
|   `testFieldDouble` DOUBLE NOT NULL,  | ||||
|   `testFieldFloat` FLOAT NOT NULL,  | ||||
|   `testFieldDecimal` DECIMAL(10,2) NOT NULL,  | ||||
|   `testFieldTimeSpan` TIME NOT NULL,  | ||||
|   `testFieldDateTime` DATETIME(3) NOT NULL,  | ||||
|   `testFieldBytes` VARBINARY(255),  | ||||
|   `testFieldString` VARCHAR(255),  | ||||
|   `testFieldGuid` VARCHAR(36),  | ||||
|   `testFieldBoolNullable` BIT(1),  | ||||
|   `testFieldSByteNullable` TINYINT(3),  | ||||
|   `testFieldShortNullable` SMALLINT(6),  | ||||
|   `testFieldIntNullable` INT(11),  | ||||
|   `testFielLongNullable` BIGINT(20),  | ||||
|   `testFieldByteNullable` TINYINT(3) UNSIGNED,  | ||||
|   `testFieldUShortNullable` SMALLINT(5) UNSIGNED,  | ||||
|   `testFieldUIntNullable` INT(10) UNSIGNED,  | ||||
|   `testFieldULongNullable` BIGINT(20) UNSIGNED,  | ||||
|   `testFieldDoubleNullable` DOUBLE,  | ||||
|   `testFieldFloatNullable` FLOAT,  | ||||
|   `testFieldDecimalNullable` DECIMAL(10,2),  | ||||
|   `testFieldTimeSpanNullable` TIME,  | ||||
|   `testFieldDateTimeNullable` DATETIME(3),  | ||||
|   `testFieldGuidNullable` VARCHAR(36),  | ||||
|   `testFieldPoint` POINT,  | ||||
|   `testFieldLineString` LINESTRING,  | ||||
|   `testFieldPolygon` POLYGON,  | ||||
|   `testFieldMultiPoint` MULTIPOINT,  | ||||
|   `testFieldMultiLineString` MULTILINESTRING,  | ||||
|   `testFieldMultiPolygon` MULTIPOLYGON,  | ||||
|   `testFieldEnum1` ENUM('E1','E2','E3') NOT NULL,  | ||||
|   `testFieldEnum1Nullable` ENUM('E1','E2','E3'),  | ||||
|   `testFieldEnum2` SET('F1','F2','F3') NOT NULL,  | ||||
|   `testFieldEnum2Nullable` SET('F1','F2','F3'),  | ||||
|   PRIMARY KEY (`Id`) | ||||
| ) Engine=InnoDB; | ||||
| ", sql); | ||||
| 			} | ||||
|  | ||||
| 			sql = g.mysql.CodeFirst.GetComparisonDDLStatements<Tb_alltype>(); | ||||
| 		} | ||||
|  | ||||
| 		IInsert<TableAllType> insert => g.mysql.Insert<TableAllType>(); | ||||
| 		ISelect<TableAllType> select => g.mysql.Select<TableAllType>(); | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void CurdAllField() { | ||||
| 			var item = new TableAllType { }; | ||||
| 			item.Id = (int)insert.AppendData(item).ExecuteIdentity(); | ||||
|  | ||||
| 			var newitem = select.Where(a => a.Id == item.Id).ToOne(); | ||||
|  | ||||
| 			var item2 = new TableAllType { | ||||
| 				testFieldBool = true, | ||||
| 				testFieldBoolNullable = true, | ||||
| 				testFieldByte = 255, | ||||
| 				testFieldByteNullable = 127, | ||||
| 				testFieldBytes = Encoding.UTF8.GetBytes("<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>"), | ||||
| 				testFieldDateTime = DateTime.Now, | ||||
| 				testFieldDateTimeNullable = DateTime.Now.AddHours(-1), | ||||
| 				testFieldDecimal = 99.99M, | ||||
| 				testFieldDecimalNullable = 99.98M, | ||||
| 				testFieldDouble = 999.99, | ||||
| 				testFieldDoubleNullable = 999.98, | ||||
| 				testFieldEnum1 = TableAllTypeEnumType1.e5, | ||||
| 				testFieldEnum1Nullable = TableAllTypeEnumType1.e3, | ||||
| 				testFieldEnum2 = TableAllTypeEnumType2.f2, | ||||
| 				testFieldEnum2Nullable = TableAllTypeEnumType2.f3, | ||||
| 				testFieldFloat = 19.99F, | ||||
| 				testFieldFloatNullable = 19.98F, | ||||
| 				testFieldGuid = Guid.NewGuid(), | ||||
| 				testFieldGuidNullable = Guid.NewGuid(), | ||||
| 				testFieldInt = int.MaxValue, | ||||
| 				testFieldIntNullable = int.MinValue, | ||||
| 				testFieldLineString = new MygisLineString(new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10) }), | ||||
| 				testFieldLong = long.MaxValue, | ||||
| 				testFieldMultiLineString = new MygisMultiLineString(new[] { | ||||
| 					new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10) }, | ||||
| 					new[] { new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 100) } }), | ||||
| 				testFieldMultiPoint = new MygisMultiPoint(new[] { new MygisCoordinate2D(11, 11), new MygisCoordinate2D(51, 11) }), | ||||
| 				testFieldMultiPolygon = new MygisMultiPolygon(new[] { | ||||
| 					new MygisPolygon(new[] { | ||||
| 						new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) }, | ||||
| 						new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) }, | ||||
| 						new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) }, | ||||
| 						new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) } }), | ||||
| 					new MygisPolygon(new[] { | ||||
| 						new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) }, | ||||
| 						new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) }, | ||||
| 						new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) }, | ||||
| 						new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) } }) }), | ||||
| 				testFieldPoint = new MygisPoint(99, 99), | ||||
| 				testFieldPolygon = new MygisPolygon(new[] { | ||||
| 					new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) }, | ||||
| 						new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) }, | ||||
| 						new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) }, | ||||
| 						new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) } }), | ||||
| 				testFieldSByte = 100, | ||||
| 				testFieldSByteNullable = 99, | ||||
| 				testFieldShort = short.MaxValue, | ||||
| 				testFieldShortNullable = short.MinValue, | ||||
| 				testFieldString = "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>string", | ||||
| 				testFieldTimeSpan = TimeSpan.FromSeconds(999), | ||||
| 				testFieldTimeSpanNullable = TimeSpan.FromSeconds(60), | ||||
| 				testFieldUInt = uint.MaxValue, | ||||
| 				testFieldUIntNullable = uint.MinValue, | ||||
| 				testFieldULong = ulong.MaxValue, | ||||
| 				testFieldULongNullable = ulong.MinValue, | ||||
| 				testFieldUShort = ushort.MaxValue, | ||||
| 				testFieldUShortNullable = ushort.MinValue, | ||||
| 				testFielLongNullable = long.MinValue | ||||
| 			}; | ||||
| 			item2.Id = (int)insert.AppendData(item2).ExecuteIdentity(); | ||||
| 			var newitem2 = select.Where(a => a.Id == item2.Id).ToOne(); | ||||
|  | ||||
| 			var items = select.ToList(); | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		[JsonObject(MemberSerialization.OptIn), Table(Name = "tb_alltype")] | ||||
| 		public partial class Tb_alltype { | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "Id", DbType = "int(11)", IsPrimary = true, IsIdentity = true)] | ||||
| 			public int Id { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldBool", DbType = "bit(1)")] | ||||
| 			public bool TestFieldBool { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldBoolNullable", DbType = "bit(1)", IsNullable = true)] | ||||
| 			public bool? TestFieldBoolNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldByte", DbType = "tinyint(3) unsigned")] | ||||
| 			public byte TestFieldByte { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldByteNullable", DbType = "tinyint(3) unsigned", IsNullable = true)] | ||||
| 			public byte? TestFieldByteNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldBytes", DbType = "varbinary(255)", IsNullable = true)] | ||||
| 			public byte[] TestFieldBytes { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldDateTime", DbType = "datetime")] | ||||
| 			public DateTime TestFieldDateTime { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldDateTimeNullable", DbType = "datetime", IsNullable = true)] | ||||
| 			public DateTime? TestFieldDateTimeNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldDecimal", DbType = "decimal(10,2)")] | ||||
| 			public decimal TestFieldDecimal { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldDecimalNullable", DbType = "decimal(10,2)", IsNullable = true)] | ||||
| 			public decimal? TestFieldDecimalNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldDouble", DbType = "double")] | ||||
| 			public double TestFieldDouble { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldDoubleNullable", DbType = "double", IsNullable = true)] | ||||
| 			public double? TestFieldDoubleNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldEnum1", DbType = "enum('E1','E2','E3','E5')")] | ||||
| 			public Tb_alltypeTESTFIELDENUM1 TestFieldEnum1 { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldEnum1Nullable", DbType = "enum('E1','E2','E3','E5')", IsNullable = true)] | ||||
| 			public Tb_alltypeTESTFIELDENUM1NULLABLE? TestFieldEnum1Nullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldEnum2", DbType = "set('F1','F2','F3')")] | ||||
| 			public Tb_alltypeTESTFIELDENUM2 TestFieldEnum2 { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldEnum2Nullable", DbType = "set('F1','F2','F3')", IsNullable = true)] | ||||
| 			public Tb_alltypeTESTFIELDENUM2NULLABLE? TestFieldEnum2Nullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldFloat", DbType = "float")] | ||||
| 			public float TestFieldFloat { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldFloatNullable", DbType = "float", IsNullable = true)] | ||||
| 			public float? TestFieldFloatNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldGuid", DbType = "char(36)")] | ||||
| 			public Guid TestFieldGuid { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldGuidNullable", DbType = "char(36)", IsNullable = true)] | ||||
| 			public Guid? TestFieldGuidNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldInt", DbType = "int(11)")] | ||||
| 			public int TestFieldInt { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldIntNullable", DbType = "int(11)", IsNullable = true)] | ||||
| 			public int? TestFieldIntNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldLineString", DbType = "linestring", IsNullable = true)] | ||||
| 			public MygisGeometry TestFieldLineString { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldLong", DbType = "bigint(20)")] | ||||
| 			public long TestFieldLong { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldMultiLineString", DbType = "multilinestring", IsNullable = true)] | ||||
| 			public MygisGeometry TestFieldMultiLineString { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldMultiPoint", DbType = "multipoint", IsNullable = true)] | ||||
| 			public MygisGeometry TestFieldMultiPoint { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldMultiPolygon", DbType = "multipolygon", IsNullable = true)] | ||||
| 			public MygisGeometry TestFieldMultiPolygon { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldPoint", DbType = "point", IsNullable = true)] | ||||
| 			public MygisGeometry TestFieldPoint { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldPolygon", DbType = "polygon", IsNullable = true)] | ||||
| 			public MygisGeometry TestFieldPolygon { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldSByte", DbType = "tinyint(3)")] | ||||
| 			public sbyte TestFieldSByte { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldSByteNullable", DbType = "tinyint(3)", IsNullable = true)] | ||||
| 			public sbyte? TestFieldSByteNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldShort", DbType = "smallint(6)")] | ||||
| 			public short TestFieldShort { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldShortNullable", DbType = "smallint(6)", IsNullable = true)] | ||||
| 			public short? TestFieldShortNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldString", DbType = "varchar(255)", IsNullable = true)] | ||||
| 			public string TestFieldString { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldTimeSpan", DbType = "time")] | ||||
| 			public TimeSpan TestFieldTimeSpan { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldTimeSpanNullable", DbType = "time", IsNullable = true)] | ||||
| 			public TimeSpan? TestFieldTimeSpanNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldUInt", DbType = "int(10) unsigned")] | ||||
| 			public uint TestFieldUInt { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldUIntNullable", DbType = "int(10) unsigned", IsNullable = true)] | ||||
| 			public uint? TestFieldUIntNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldULong", DbType = "bigint(20) unsigned")] | ||||
| 			public ulong TestFieldULong { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldULongNullable", DbType = "bigint(20) unsigned", IsNullable = true)] | ||||
| 			public ulong? TestFieldULongNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldUShort", DbType = "smallint(5) unsigned")] | ||||
| 			public ushort TestFieldUShort { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFieldUShortNullable", DbType = "smallint(5) unsigned", IsNullable = true)] | ||||
| 			public ushort? TestFieldUShortNullable { get; set; } | ||||
|  | ||||
|  | ||||
| 			[JsonProperty, Column(Name = "testFielLongNullable", DbType = "bigint(20)", IsNullable = true)] | ||||
| 			public long? TestFielLongNullable { get; set; } | ||||
|  | ||||
| 			internal static IFreeSql mysql => null; | ||||
| 			public static FreeSql.ISelect<Tb_alltype> Select => mysql.Select<Tb_alltype>(); | ||||
|  | ||||
| 			public static long Delete(int Id) { | ||||
| 				var affrows = mysql.Delete<Tb_alltype>().Where(a => a.Id == Id).ExecuteAffrows(); | ||||
| 				return affrows; | ||||
| 			} | ||||
|  | ||||
| 			/// <summary> | ||||
| 			/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Update<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ 0 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Insert | ||||
| 			/// </summary> | ||||
| 			public void Save() { | ||||
| 				if (this.Id != default(int)) { | ||||
| 					var affrows = mysql.Update<Tb_alltype>().Where(a => a.Id == Id).ExecuteAffrows(); | ||||
| 					if (affrows > 0) return; | ||||
| 				} | ||||
| 				this.Id = (int)mysql.Insert<Tb_alltype>().AppendData(this).ExecuteIdentity(); | ||||
| 			} | ||||
|  | ||||
| 		} | ||||
|  | ||||
| 		public enum Tb_alltypeTESTFIELDENUM1 { | ||||
| 			E1 = 1, E2, E3, E5 | ||||
| 		} | ||||
| 		public enum Tb_alltypeTESTFIELDENUM1NULLABLE { | ||||
| 			E1 = 1, E2, E3, E5 | ||||
| 		} | ||||
| 		[Flags] | ||||
| 		public enum Tb_alltypeTESTFIELDENUM2 : long { | ||||
| 			F1 = 1, F2 = 2, F3 = 4 | ||||
| 		} | ||||
| 		[Flags] | ||||
| 		public enum Tb_alltypeTESTFIELDENUM2NULLABLE : long { | ||||
| 			F1 = 1, F2 = 2, F3 = 4 | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		[Table(Name = "tb_alltype")] | ||||
| 		class TableAllType { | ||||
| 			[Column(IsIdentity = true, IsPrimary = true)] | ||||
| 			public int Id { get; set; } | ||||
|  | ||||
| 			public bool testFieldBool { get; set; } | ||||
| 			public sbyte testFieldSByte { get; set; } | ||||
| 			public short testFieldShort { get; set; } | ||||
| 			public int testFieldInt { get; set; } | ||||
| 			public long testFieldLong { get; set; } | ||||
| 			public byte testFieldByte { get; set; } | ||||
| 			public ushort testFieldUShort { get; set; } | ||||
| 			public uint testFieldUInt { get; set; } | ||||
| 			public ulong testFieldULong { get; set; } | ||||
| 			public double testFieldDouble { get; set; } | ||||
| 			public float testFieldFloat { get; set; } | ||||
| 			public decimal testFieldDecimal { get; set; } | ||||
| 			public TimeSpan testFieldTimeSpan { get; set; } | ||||
| 			public DateTime testFieldDateTime { get; set; } | ||||
| 			public byte[] testFieldBytes { get; set; } | ||||
| 			public string testFieldString { get; set; } | ||||
| 			public Guid testFieldGuid { get; set; } | ||||
|  | ||||
| 			public bool? testFieldBoolNullable { get; set; } | ||||
| 			public sbyte? testFieldSByteNullable { get; set; } | ||||
| 			public short? testFieldShortNullable { get; set; } | ||||
| 			public int? testFieldIntNullable { get; set; } | ||||
| 			public long? testFielLongNullable { get; set; } | ||||
| 			public byte? testFieldByteNullable { get; set; } | ||||
| 			public ushort? testFieldUShortNullable { get; set; } | ||||
| 			public uint? testFieldUIntNullable { get; set; } | ||||
| 			public ulong? testFieldULongNullable { get; set; } | ||||
| 			public double? testFieldDoubleNullable { get; set; } | ||||
| 			public float? testFieldFloatNullable { get; set; } | ||||
| 			public decimal? testFieldDecimalNullable { get; set; } | ||||
| 			public TimeSpan? testFieldTimeSpanNullable { get; set; } | ||||
| 			public DateTime? testFieldDateTimeNullable { get; set; } | ||||
| 			public Guid? testFieldGuidNullable { get; set; } | ||||
|  | ||||
| 			public MygisPoint testFieldPoint { get; set; } | ||||
| 			public MygisLineString testFieldLineString { get; set; } | ||||
| 			public MygisPolygon testFieldPolygon { get; set; } | ||||
| 			public MygisMultiPoint testFieldMultiPoint { get; set; } | ||||
| 			public MygisMultiLineString testFieldMultiLineString { get; set; } | ||||
| 			public MygisMultiPolygon testFieldMultiPolygon { get; set; } | ||||
|  | ||||
| 			public TableAllTypeEnumType1 testFieldEnum1 { get; set; } | ||||
| 			public TableAllTypeEnumType1? testFieldEnum1Nullable { get; set; } | ||||
| 			public TableAllTypeEnumType2 testFieldEnum2 { get; set; } | ||||
| 			public TableAllTypeEnumType2? testFieldEnum2Nullable { get; set; } | ||||
| 		} | ||||
|  | ||||
| 		public enum TableAllTypeEnumType1 { e1, e2, e3, e5 } | ||||
| 		[Flags] public enum TableAllTypeEnumType2 { f1, f2, f3 } | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,54 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using System; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnector { | ||||
| 	public class MySqlAdoTest { | ||||
| 		[Fact] | ||||
| 		public void Pool() { | ||||
| 			var t1 = g.mysql.Ado.MasterPool.StatisticsFullily; | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void SlavePools() { | ||||
| 			var t2 = g.mysql.Ado.SlavePools.Count; | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void ExecuteReader() { | ||||
| 			 | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ExecuteArray() { | ||||
| 			 | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ExecuteNonQuery() { | ||||
| 			 | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ExecuteScalar() { | ||||
| 			 | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void Query() { | ||||
| 			var t3 = g.mysql.Ado.Query<xxx>("select * from song"); | ||||
|  | ||||
| 			var t4 = g.mysql.Ado.Query<(int, string, string)>("select * from song"); | ||||
|  | ||||
| 			var t5 = g.mysql.Ado.Query<dynamic>("select * from song"); | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void QueryMultipline() { | ||||
| 			var t3 = g.mysql.Ado.Query<xxx, (int, string, string), dynamic>("select * from song; select * from song; select * from song"); | ||||
| 		} | ||||
|  | ||||
| 		class xxx { | ||||
| 			public int Id { get; set; } | ||||
| 			public string Path { get; set; } | ||||
| 			public string Title2 { get; set; } | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,146 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnectorExpression { | ||||
| 	public class ConvertTest { | ||||
|  | ||||
| 		ISelect<Topic> select => g.mysql.Select<Topic>(); | ||||
|  | ||||
| 		[Table(Name = "tb_topic")] | ||||
| 		class Topic { | ||||
| 			[Column(IsIdentity = true, IsPrimary = true)] | ||||
| 			public int Id { get; set; } | ||||
| 			public int Clicks { get; set; } | ||||
| 			public int TypeGuid { get; set; } | ||||
| 			public TestTypeInfo Type { get; set; } | ||||
| 			public string Title { get; set; } | ||||
| 			public DateTime CreateTime { get; set; } | ||||
| 		} | ||||
| 		class TestTypeInfo { | ||||
| 			public int Guid { get; set; } | ||||
| 			public int ParentId { get; set; } | ||||
| 			public TestTypeParentInfo Parent { get; set; } | ||||
| 			public string Name { get; set; } | ||||
| 		} | ||||
| 		class TestTypeParentInfo { | ||||
| 			public int Id { get; set; } | ||||
| 			public string Name { get; set; } | ||||
|  | ||||
| 			public List<TestTypeInfo> Types { get; set; } | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void ToBoolean() { | ||||
| 			var data = new List<object>(); | ||||
| 			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] | ||||
| 		public void ToByte() { | ||||
| 			var data = new List<object>(); | ||||
| 			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] | ||||
| 		public void ToChar() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Convert.ToChar(a.Clicks) == '1').ToList()); | ||||
| 			data.Add(select.Where(a => char.Parse(a.Clicks.ToString()) == '1').ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ToDateTime() { | ||||
| 			var data = new List<object>(); | ||||
| 			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] | ||||
| 		public void ToDecimal() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Convert.ToDecimal(a.Clicks) > 0).ToList()); | ||||
| 			data.Add(select.Where(a => decimal.Parse(a.Clicks.ToString()) > 0).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ToDouble() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Convert.ToDouble(a.Clicks) > 0).ToList()); | ||||
| 			data.Add(select.Where(a => double.Parse(a.Clicks.ToString()) > 0).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ToInt16() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Convert.ToInt16(a.Clicks) > 0).ToList()); | ||||
| 			data.Add(select.Where(a => short.Parse(a.Clicks.ToString()) > 0).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ToInt32() { | ||||
| 			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 => int.Parse(a.Clicks.ToString()) > 0).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ToInt64() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Convert.ToInt64(a.Clicks) > 0).ToList()); | ||||
| 			data.Add(select.Where(a => long.Parse(a.Clicks.ToString()) > 0).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ToSByte() { | ||||
| 			var data = new List<object>(); | ||||
| 			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] | ||||
| 		public void ToSingle() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Convert.ToSingle(a.Clicks) > 0).ToList()); | ||||
| 			data.Add(select.Where(a => float.Parse(a.Clicks.ToString()) > 0).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void this_ToString() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Convert.ToString(a.Clicks).Equals("")).ToList()); | ||||
| 			data.Add(select.Where(a => a.Clicks.ToString().Equals("")).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ToUInt16() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Convert.ToUInt16(a.Clicks) > 0).ToList()); | ||||
| 			data.Add(select.Where(a => ushort.Parse(a.Clicks.ToString()) > 0).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ToUInt32() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Convert.ToUInt32(a.Clicks) > 0).ToList()); | ||||
| 			data.Add(select.Where(a => uint.Parse(a.Clicks.ToString()) > 0).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ToUInt64() { | ||||
| 			var data = new List<object>(); | ||||
| 			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()); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,623 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnectorExpression { | ||||
| 	public class DateTimeTest { | ||||
|  | ||||
| 		ISelect<Topic> select => g.mysql.Select<Topic>(); | ||||
|  | ||||
| 		[Table(Name = "tb_topic111333")] | ||||
| 		class Topic { | ||||
| 			[Column(IsIdentity = true, IsPrimary = true)] | ||||
| 			public int Id { get; set; } | ||||
| 			public int Clicks { get; set; } | ||||
| 			public int TypeGuid { get; set; } | ||||
| 			public TestTypeInfo Type { get; set; } | ||||
| 			public string Title { get; set; } | ||||
| 			public DateTime CreateTime { get; set; } | ||||
| 		} | ||||
| 		[Table(Name = "TestTypeInfo333")] | ||||
| 		class TestTypeInfo { | ||||
| 			[Column(IsIdentity = true)] | ||||
| 			public int Guid { get; set; } | ||||
| 			public int ParentId { get; set; } | ||||
| 			public TestTypeParentInfo Parent { get; set; } | ||||
| 			public string Name { get; set; } | ||||
| 			public DateTime Time { get; set; } | ||||
| 		} | ||||
| 		[Table(Name = "TestTypeParentInfo23123")] | ||||
| 		class TestTypeParentInfo { | ||||
| 			public int Id { get; set; } | ||||
| 			public string Name { get; set; } | ||||
|  | ||||
| 			public List<TestTypeInfo> Types { get; set; } | ||||
| 			public DateTime Time2 { get; set; } | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Now() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Date == DateTime.Now.Date).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(now(), '%Y-%m-%d') as datetime)) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void UtcNow() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Date == DateTime.UtcNow.Date).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(utc_timestamp(), '%Y-%m-%d') as datetime)) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void MinValue() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Date == DateTime.MinValue.Date).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(cast('0001/1/1 0:00:00' as datetime), '%Y-%m-%d') as datetime)) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void MaxValue() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Date == DateTime.MaxValue.Date).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(cast('9999/12/31 23:59:59' as datetime), '%Y-%m-%d') as datetime)) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Date() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Date == DateTime.Now.Date).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.Date > DateTime.Now.Date).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.Date > DateTime.Now.Date).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(now(), '%Y-%m-%d') as datetime)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (cast(date_format(a__Type.`Time`, '%Y-%m-%d') as datetime) > cast(date_format(now(), '%Y-%m-%d') as datetime)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (cast(date_format(a__Type__Parent.`Time2`, '%Y-%m-%d') as datetime) > cast(date_format(now(), '%Y-%m-%d') as datetime)); | ||||
| 			data.Add(select.Where(a => DateTime.Now.Subtract(a.CreateTime.Date).TotalSeconds > 0).ToList()); | ||||
| 			data.Add(select.Where(a => DateTime.Now.Subtract(a.Type.Time.Date).TotalSeconds > 0).ToList()); | ||||
| 			data.Add(select.Where(a => DateTime.Now.Subtract(a.Type.Parent.Time2.Date).TotalSeconds > 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (((timestampdiff(microsecond, cast(date_format(a__Type.`Time`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (((timestampdiff(microsecond, cast(date_format(a__Type__Parent.`Time2`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TimeOfDay() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay == DateTime.Now.TimeOfDay).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.TimeOfDay > DateTime.Now.TimeOfDay).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.TimeOfDay > DateTime.Now.TimeOfDay).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE ((timestampdiff(microsecond, date_format(a__Type.`Time`, '1970-1-1 %H:%i:%s.%f'), a__Type.`Time`) + 62135596800000000) > (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE ((timestampdiff(microsecond, date_format(a__Type__Parent.`Time2`, '1970-1-1 %H:%i:%s.%f'), a__Type__Parent.`Time2`) + 62135596800000000) > (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000)) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void DayOfWeek() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.DayOfWeek > DateTime.Now.DayOfWeek).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE ((dayofweek(a.`CreateTime`) - 1) > (dayofweek(now()) - 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE ((dayofweek(a__Type.`Time`) - 1) > (dayofweek(now()) - 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE ((dayofweek(a__Type__Parent.`Time2`) - 1) > (dayofweek(now()) - 1)) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Day() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Day > DateTime.Now.Day).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.Day > DateTime.Now.Day).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.Day > DateTime.Now.Day).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (dayofmonth(a.`CreateTime`) > dayofmonth(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (dayofmonth(a__Type.`Time`) > dayofmonth(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (dayofmonth(a__Type__Parent.`Time2`) > dayofmonth(now())) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void DayOfYear() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.DayOfYear > DateTime.Now.DayOfYear).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.DayOfYear > DateTime.Now.DayOfYear).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.DayOfYear > DateTime.Now.DayOfYear).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (dayofyear(a.`CreateTime`) > dayofyear(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (dayofyear(a__Type.`Time`) > dayofyear(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (dayofyear(a__Type__Parent.`Time2`) > dayofyear(now())) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Month() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Month > DateTime.Now.Month).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.Month > DateTime.Now.Month).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.Month > DateTime.Now.Month).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (month(a.`CreateTime`) > month(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (month(a__Type.`Time`) > month(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (month(a__Type__Parent.`Time2`) > month(now())) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Year() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Year > DateTime.Now.Year).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.Year > DateTime.Now.Year).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.Year > DateTime.Now.Year).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (year(a.`CreateTime`) > year(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (year(a__Type.`Time`) > year(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (year(a__Type__Parent.`Time2`) > year(now())) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Hour() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Hour > DateTime.Now.Hour).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.Hour > DateTime.Now.Hour).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.Hour > DateTime.Now.Hour).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (hour(a.`CreateTime`) > hour(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (hour(a__Type.`Time`) > hour(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (hour(a__Type__Parent.`Time2`) > hour(now())) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Minute() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Minute > DateTime.Now.Minute).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.Minute > DateTime.Now.Minute).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.Minute > DateTime.Now.Minute).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (minute(a.`CreateTime`) > minute(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (minute(a__Type.`Time`) > minute(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (minute(a__Type__Parent.`Time2`) > minute(now())) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Second() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Second > DateTime.Now.Second).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.Second > DateTime.Now.Second).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.Second > DateTime.Now.Second).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (second(a.`CreateTime`) > second(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (second(a__Type.`Time`) > second(now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (second(a__Type__Parent.`Time2`) > second(now())) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Millisecond() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Millisecond > DateTime.Now.Millisecond).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.Millisecond > DateTime.Now.Millisecond).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.Millisecond > DateTime.Now.Millisecond).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (floor(microsecond(a.`CreateTime`) / 1000) > floor(microsecond(now()) / 1000)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (floor(microsecond(a__Type.`Time`) / 1000) > floor(microsecond(now()) / 1000)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (floor(microsecond(a__Type__Parent.`Time2`) / 1000) > floor(microsecond(now()) / 1000)) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Ticks() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Ticks > DateTime.Now.Ticks).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.Ticks > DateTime.Now.Ticks).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.Ticks > DateTime.Now.Ticks).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE ((timestampdiff(microsecond, '1970-1-1', a.`CreateTime`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE ((timestampdiff(microsecond, '1970-1-1', a__Type.`Time`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE ((timestampdiff(microsecond, '1970-1-1', a__Type__Parent.`Time2`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000)) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Add() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (date_add(a.`CreateTime`, interval ((1 * 86400000000)) microsecond) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (date_add(a__Type.`Time`, interval ((1 * 86400000000)) microsecond) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (date_add(a__Type__Parent.`Time2`, interval ((1 * 86400000000)) microsecond) > now()) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void AddDays() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.AddDays(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.AddDays(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.AddDays(1) > DateTime.Now).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (date_add(a.`CreateTime`, interval (1) day) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (date_add(a__Type.`Time`, interval (1) day) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) day) > now()) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void AddHours() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.AddHours(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.AddHours(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.AddHours(1) > DateTime.Now).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (date_add(a.`CreateTime`, interval (1) hour) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (date_add(a__Type.`Time`, interval (1) hour) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) hour) > now()) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void AddMilliseconds() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.AddMilliseconds(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.AddMilliseconds(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.AddMilliseconds(1) > DateTime.Now).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (date_add(a.`CreateTime`, interval (1) * 1000 microsecond) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (date_add(a__Type.`Time`, interval (1) * 1000 microsecond) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) * 1000 microsecond) > now()) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void AddMinutes() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.AddMinutes(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.AddMinutes(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.AddMinutes(1) > DateTime.Now).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (date_add(a.`CreateTime`, interval (1) minute) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (date_add(a__Type.`Time`, interval (1) minute) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) minute) > now()) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void AddMonths() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.AddMonths(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.AddMonths(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.AddMonths(1) > DateTime.Now).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (date_add(a.`CreateTime`, interval (1) month) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (date_add(a__Type.`Time`, interval (1) month) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) month) > now()) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void AddSeconds() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.AddSeconds(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.AddSeconds(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.AddSeconds(1) > DateTime.Now).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (date_add(a.`CreateTime`, interval (1) second) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (date_add(a__Type.`Time`, interval (1) second) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) second) > now()) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void AddTicks() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.AddTicks(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.AddTicks(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.AddTicks(1) > DateTime.Now).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (date_add(a.`CreateTime`, interval (1) / 10 microsecond) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (date_add(a__Type.`Time`, interval (1) / 10 microsecond) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) / 10 microsecond) > now()) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void AddYears() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.AddYears(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.AddYears(1) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1) > DateTime.Now).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (date_add(a.`CreateTime`, interval (1) year) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (date_add(a__Type.`Time`, interval (1) year) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) year) > now()) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Subtract() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.Subtract(DateTime.Now).TotalSeconds > 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, now(), a.`CreateTime`)) / 1000000) > 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (((timestampdiff(microsecond, now(), a__Type.`Time`)) / 1000000) > 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (((timestampdiff(microsecond, now(), a__Type__Parent.`Time2`)) / 1000000) > 0); | ||||
| 			data.Add(select.Where(a => a.CreateTime.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (date_sub(a.`CreateTime`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (date_sub(a__Type.`Time`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (date_sub(a__Type__Parent.`Time2`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void this_Equals() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.AddYears(1).Equals(DateTime.Now)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.AddYears(1).Equals(DateTime.Now)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).Equals(DateTime.Now)).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE ((date_add(a.`CreateTime`, interval (1) year) = now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE ((date_add(a__Type.`Time`, interval (1) year) = now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE ((date_add(a__Type__Parent.`Time2`, interval (1) year) = now())) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void this_ToString() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.ToString().Equals(DateTime.Now)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.AddYears(1).ToString().Equals(DateTime.Now)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).ToString().Equals(DateTime.Now)).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE ((date_format(a.`CreateTime`, '%Y-%m-%d %H:%i:%s.%f') = now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE ((date_format(date_add(a__Type.`Time`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') = now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE ((date_format(date_add(a__Type__Parent.`Time2`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') = now())) | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void DateTime_Compare() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.CompareTo(DateTime.Now) == 0).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Time.AddYears(1).CompareTo(DateTime.Now) == 0).ToList()); | ||||
| 			data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).CompareTo(DateTime.Now) == 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (((a.`CreateTime`) - (now())) = 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (((date_add(a__Type.`Time`, interval (1) year)) - (now())) = 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (((date_add(a__Type__Parent.`Time2`, interval (1) year)) - (now())) = 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void DateTime_DaysInMonth() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => DateTime.DaysInMonth(a.CreateTime.Year, a.CreateTime.Month) > 30).ToList()); | ||||
| 			data.Add(select.Where(a => DateTime.DaysInMonth(a.Type.Time.Year, a.Type.Time.Month) > 30).ToList()); | ||||
| 			data.Add(select.Where(a => DateTime.DaysInMonth(a.Type.Parent.Time2.Year, a.Type.Parent.Time2.Month) > 30).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (dayofmonth(last_day(concat(year(a.`CreateTime`), month(a.`CreateTime`), '-01'))) > 30); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (dayofmonth(last_day(concat(year(a__Type.`Time`), month(a__Type.`Time`), '-01'))) > 30); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (dayofmonth(last_day(concat(year(a__Type__Parent.`Time2`), month(a__Type__Parent.`Time2`), '-01'))) > 30) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void DateTime_Equals() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => DateTime.Equals(a.CreateTime.AddYears(1), DateTime.Now)).ToList()); | ||||
| 			data.Add(select.Where(a => DateTime.Equals(a.Type.Time.AddYears(1), DateTime.Now)).ToList()); | ||||
| 			data.Add(select.Where(a => DateTime.Equals(a.Type.Parent.Time2.AddYears(1), DateTime.Now)).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE ((date_add(a.`CreateTime`, interval (1) year) = now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE ((date_add(a__Type.`Time`, interval (1) year) = now())); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE ((date_add(a__Type__Parent.`Time2`, interval (1) year) = now())) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void DateTime_IsLeapYear() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => DateTime.IsLeapYear(a.CreateTime.Year)).ToList()); | ||||
| 			data.Add(select.Where(a => DateTime.IsLeapYear(a.Type.Time.AddYears(1).Year)).ToList()); | ||||
| 			data.Add(select.Where(a => DateTime.IsLeapYear(a.Type.Parent.Time2.AddYears(1).Year)).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (((year(a.`CreateTime`)) % 4 = 0 AND (year(a.`CreateTime`)) % 100 <> 0 OR (year(a.`CreateTime`)) % 400 = 0)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (((year(date_add(a__Type.`Time`, interval (1) year))) % 4 = 0 AND (year(date_add(a__Type.`Time`, interval (1) year))) % 100 <> 0 OR (year(date_add(a__Type.`Time`, interval (1) year))) % 400 = 0)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (((year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 4 = 0 AND (year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 100 <> 0 OR (year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 400 = 0)) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void DateTime_Parse() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => DateTime.Parse(a.CreateTime.ToString()) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => DateTime.Parse(a.Type.Time.AddYears(1).ToString()) > DateTime.Now).ToList()); | ||||
| 			data.Add(select.Where(a => DateTime.Parse(a.Type.Parent.Time2.AddYears(1).ToString()) > DateTime.Now).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic111333` a  | ||||
| 			//WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type  | ||||
| 			//WHERE (cast(date_format(date_add(a__Type.`Time`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9  | ||||
| 			//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent  | ||||
| 			//WHERE (cast(date_format(date_add(a__Type__Parent.`Time2`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') as datetime) > now()) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,132 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnectorExpression { | ||||
| 	public class MathTest { | ||||
|  | ||||
| 		ISelect<Topic> select => g.mysql.Select<Topic>(); | ||||
|  | ||||
| 		[Table(Name = "tb_topic")] | ||||
| 		class Topic { | ||||
| 			[Column(IsIdentity = true, IsPrimary = true)] | ||||
| 			public int Id { get; set; } | ||||
| 			public int Clicks { get; set; } | ||||
| 			public int TypeGuid { get; set; } | ||||
| 			public TestTypeInfo Type { get; set; } | ||||
| 			public string Title { get; set; } | ||||
| 			public DateTime CreateTime { get; set; } | ||||
| 		} | ||||
| 		class TestTypeInfo { | ||||
| 			public int Guid { get; set; } | ||||
| 			public int ParentId { get; set; } | ||||
| 			public TestTypeParentInfo Parent { get; set; } | ||||
| 			public string Name { get; set; } | ||||
| 		} | ||||
| 		class TestTypeParentInfo { | ||||
| 			public int Id { get; set; } | ||||
| 			public string Name { get; set; } | ||||
|  | ||||
| 			public List<TestTypeInfo> Types { get; set; } | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void PI() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.PI + a.Clicks > 0).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Abs() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Abs(-a.Clicks) > 0).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Sign() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Sign(-a.Clicks) > 0).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Floor() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Floor(a.Clicks + 0.5) == a.Clicks).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Ceiling() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Ceiling(a.Clicks + 0.5) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Round() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Round(a.Clicks + 0.5) == a.Clicks).ToList()); | ||||
| 			data.Add(select.Where(a => Math.Round(a.Clicks + 0.5, 1) > a.Clicks).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Exp() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Exp(1) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Log() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Log(a.Clicks + 0.5) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Log10() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Log10(a.Clicks + 0.5) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Pow() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Pow(2, a.Clicks) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Sqrt() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Sqrt(Math.Pow(2, a.Clicks)) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Cos() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Cos(Math.Pow(2, a.Clicks)) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Sin() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Sin(Math.Pow(2, a.Clicks)) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Tan() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Tan(Math.Pow(2, a.Clicks)) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Acos() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Acos(Math.Pow(2, a.Clicks)) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Asin() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Asin(Math.Pow(2, a.Clicks)) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Atan() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Atan(Math.Pow(2, a.Clicks)) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Atan2() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Atan2(2, a.Clicks) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Truncate() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => Math.Truncate(a.Clicks * 1.0 / 3) == a.Clicks + 1).ToList()); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,121 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using MySql.Data.MySqlClient; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnectorExpression { | ||||
| 	public class OtherTest { | ||||
|  | ||||
| 		ISelect<TableAllType> select => g.mysql.Select<TableAllType>(); | ||||
|  | ||||
| 		public OtherTest() { | ||||
| 			 | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void Boolean() { | ||||
| 			var t1 = select.Where(a => a.testFieldBool == true).ToList(); | ||||
| 			var t2 = select.Where(a => a.testFieldBool != true).ToList(); | ||||
| 			var t3 = select.Where(a => a.testFieldBool == false).ToList(); | ||||
| 			var t4 = select.Where(a => !a.testFieldBool).ToList(); | ||||
| 			var t5 = select.Where(a => a.testFieldBool).ToList(); | ||||
|  | ||||
| 			var t11 = select.Where(a => a.testFieldBoolNullable == true).ToList(); | ||||
| 			var t22 = select.Where(a => a.testFieldBoolNullable != true).ToList(); | ||||
| 			var t33 = select.Where(a => a.testFieldBoolNullable == false).ToList(); | ||||
| 			var t44 = select.Where(a => !a.testFieldBoolNullable.Value).ToList(); | ||||
| 			var t55 = select.Where(a => a.testFieldBoolNullable.Value).ToList(); | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void Array() { | ||||
| 			int[] nullarr = null; | ||||
| 			Assert.Throws<MySqlException>(() => { select.Where(a => nullarr.Contains(a.testFieldInt)).ToList(); }); | ||||
| 			Assert.Throws<MySqlException>(() => { select.Where(a => new int[0].Contains(a.testFieldInt)).ToList(); }); | ||||
|  | ||||
| 			IEnumerable<int> testlinqlist = new List<int>(new[] { 1, 2, 3 }); | ||||
| 			var testlinq = select.Where(a => testlinqlist.Contains(a.testFieldInt)).ToList(); | ||||
|  | ||||
| 			//in not in | ||||
| 			var sql111 = select.Where(a => new[] { 1, 2, 3 }.Contains(a.testFieldInt)).ToList(); | ||||
| 			var sql112 = select.Where(a => new[] { 1, 2, 3 }.Contains(a.testFieldInt) == false).ToList(); | ||||
| 			var sql113 = select.Where(a => !new[] { 1, 2, 3 }.Contains(a.testFieldInt)).ToList(); | ||||
|  | ||||
| 			var inarray = new[] { 1, 2, 3 }; | ||||
| 			var sql1111 = select.Where(a => inarray.Contains(a.testFieldInt)).ToList(); | ||||
| 			var sql1122 = select.Where(a => inarray.Contains(a.testFieldInt) == false).ToList(); | ||||
| 			var sql1133 = select.Where(a => !inarray.Contains(a.testFieldInt)).ToList(); | ||||
|  | ||||
| 			//in not in | ||||
| 			var sql11111 = select.Where(a => new List<int>() { 1, 2, 3 }.Contains(a.testFieldInt)).ToList(); | ||||
| 			var sql11222 = select.Where(a => new List<int>() { 1, 2, 3 }.Contains(a.testFieldInt) == false).ToList(); | ||||
| 			var sql11333 = select.Where(a => !new List<int>() { 1, 2, 3 }.Contains(a.testFieldInt)).ToList(); | ||||
|  | ||||
| 			var sql11111a = select.Where(a => new List<int>(new[] { 1, 2, 3 }).Contains(a.testFieldInt)).ToList(); | ||||
| 			var sql11222b = select.Where(a => new List<int>(new[] { 1, 2, 3 }).Contains(a.testFieldInt) == false).ToList(); | ||||
| 			var sql11333c = select.Where(a => !new List<int>(new[] { 1, 2, 3 }).Contains(a.testFieldInt)).ToList(); | ||||
|  | ||||
| 			var inarray2 = new List<int>() { 1, 2, 3 }; | ||||
| 			var sql111111 = select.Where(a => inarray.Contains(a.testFieldInt)).ToList(); | ||||
| 			var sql112222 = select.Where(a => inarray.Contains(a.testFieldInt) == false).ToList(); | ||||
| 			var sql113333 = select.Where(a => !inarray.Contains(a.testFieldInt)).ToList(); | ||||
| 		} | ||||
|  | ||||
| 		[Table(Name = "tb_alltype")] | ||||
| 		class TableAllType { | ||||
| 			[Column(IsIdentity = true, IsPrimary = true)] | ||||
| 			public int Id { get; set; } | ||||
|  | ||||
| 			public bool testFieldBool { get; set; } | ||||
| 			public sbyte testFieldSByte { get; set; } | ||||
| 			public short testFieldShort { get; set; } | ||||
| 			public int testFieldInt { get; set; } | ||||
| 			public long testFieldLong { get; set; } | ||||
| 			public byte testFieldByte { get; set; } | ||||
| 			public ushort testFieldUShort { get; set; } | ||||
| 			public uint testFieldUInt { get; set; } | ||||
| 			public ulong testFieldULong { get; set; } | ||||
| 			public double testFieldDouble { get; set; } | ||||
| 			public float testFieldFloat { get; set; } | ||||
| 			public decimal testFieldDecimal { get; set; } | ||||
| 			public TimeSpan testFieldTimeSpan { get; set; } | ||||
| 			public DateTime testFieldDateTime { get; set; } | ||||
| 			public byte[] testFieldBytes { get; set; } | ||||
| 			public string testFieldString { get; set; } | ||||
| 			public Guid testFieldGuid { get; set; } | ||||
|  | ||||
| 			public bool? testFieldBoolNullable { get; set; } | ||||
| 			public sbyte? testFieldSByteNullable { get; set; } | ||||
| 			public short? testFieldShortNullable { get; set; } | ||||
| 			public int? testFieldIntNullable { get; set; } | ||||
| 			public long? testFielLongNullable { get; set; } | ||||
| 			public byte? testFieldByteNullable { get; set; } | ||||
| 			public ushort? testFieldUShortNullable { get; set; } | ||||
| 			public uint? testFieldUIntNullable { get; set; } | ||||
| 			public ulong? testFieldULongNullable { get; set; } | ||||
| 			public double? testFieldDoubleNullable { get; set; } | ||||
| 			public float? testFieldFloatNullable { get; set; } | ||||
| 			public decimal? testFieldDecimalNullable { get; set; } | ||||
| 			public TimeSpan? testFieldTimeSpanNullable { get; set; } | ||||
| 			public DateTime? testFieldDateTimeNullable { get; set; } | ||||
| 			public Guid? testFieldGuidNullable { get; set; } | ||||
|  | ||||
| 			public MygisPoint testFieldPoint { get; set; } | ||||
| 			public MygisLineString testFieldLineString { get; set; } | ||||
| 			public MygisPolygon testFieldPolygon { get; set; } | ||||
| 			public MygisMultiPoint testFieldMultiPoint { get; set; } | ||||
| 			public MygisMultiLineString testFieldMultiLineString { get; set; } | ||||
| 			public MygisMultiPolygon testFieldMultiPolygon { get; set; } | ||||
|  | ||||
| 			public TableAllTypeEnumType1 testFieldEnum1 { get; set; } | ||||
| 			public TableAllTypeEnumType1? testFieldEnum1Nullable { get; set; } | ||||
| 			public TableAllTypeEnumType2 testFieldEnum2 { get; set; } | ||||
| 			public TableAllTypeEnumType2? testFieldEnum2Nullable { get; set; } | ||||
| 		} | ||||
|  | ||||
| 		public enum TableAllTypeEnumType1 { e1, e2, e3, e5 } | ||||
| 		[Flags] public enum TableAllTypeEnumType2 { f1, f2, f3 } | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,696 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnectorExpression { | ||||
| 	public class StringTest { | ||||
|  | ||||
| 		ISelect<Topic> select => g.mysql.Select<Topic>(); | ||||
|  | ||||
| 		[Table(Name = "tb_topic")] | ||||
| 		class Topic { | ||||
| 			[Column(IsIdentity = true, IsPrimary = true)] | ||||
| 			public int Id { get; set; } | ||||
| 			public int Clicks { get; set; } | ||||
| 			public int TypeGuid { get; set; } | ||||
| 			public TestTypeInfo Type { get; set; } | ||||
| 			public string Title { get; set; } | ||||
| 			public DateTime CreateTime { get; set; } | ||||
| 		} | ||||
| 		class TestTypeInfo { | ||||
| 			[Column(IsIdentity = true)] | ||||
| 			public int Guid { get; set; } | ||||
| 			public int ParentId { get; set; } | ||||
| 			public TestTypeParentInfo Parent { get; set; } | ||||
| 			public string Name { get; set; } | ||||
| 		} | ||||
| 		class TestTypeParentInfo { | ||||
| 			public int Id { get; set; } | ||||
| 			public string Name { get; set; } | ||||
|  | ||||
| 			public List<TestTypeInfo> Types { get; set; } | ||||
| 		} | ||||
| 		class TestEqualsGuid { | ||||
| 			public Guid id { get; set; } | ||||
| 			public bool IsDeleted { get; set; } | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void Equals__() { | ||||
| 			var list = new List<object>(); | ||||
| 			list.Add(select.Where(a => a.Title.Equals("aaa")).ToList()); | ||||
| 			list.Add(g.mysql.Select<TestEqualsGuid>().Where(a => a.id.Equals(Guid.Empty)).ToList()); | ||||
| 			list.Add(g.mysql.Select<TestEqualsGuid>().Where(a => a.IsDeleted.Equals(false)).ToList()); | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void Empty() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => (a.Title ?? "") == string.Empty).ToSql()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (ifnull(a.`Title`, '') = '') | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void StartsWith() { | ||||
| 			var list = new List<object>(); | ||||
| 			list.Add(select.Where(a => a.Title.StartsWith("aaa")).ToList()); | ||||
| 			list.Add(select.Where(a => a.Title.StartsWith(a.Title)).ToList()); | ||||
| 			list.Add(select.Where(a => a.Title.StartsWith(a.Title + 1)).ToList()); | ||||
| 			list.Add(select.Where(a => a.Title.StartsWith(a.Type.Name)).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((a.`Title`) LIKE '%aaa') | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((a.`Title`) LIKE concat('%', a.`Title`)) | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((a.`Title`) LIKE concat('%', concat(a.`Title`, 1))) | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type | ||||
| 			//WHERE((a.`Title`) LIKE concat('%', a__Type.`Name`)) | ||||
| 			list.Add(select.Where(a => (a.Title + "aaa").StartsWith("aaa")).ToList()); | ||||
| 			list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Title)).ToList()); | ||||
| 			list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Title + 1)).ToList()); | ||||
| 			list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Type.Name)).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((concat(a.`Title`, 'aaa')) LIKE '%aaa') | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a.`Title`)) | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', concat(a.`Title`, 1))) | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type | ||||
| 			//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`)) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void EndsWith() { | ||||
| 			var list = new List<object>(); | ||||
| 			list.Add(select.Where(a => a.Title.EndsWith("aaa")).ToList()); | ||||
| 			list.Add(select.Where(a => a.Title.EndsWith(a.Title)).ToList()); | ||||
| 			list.Add(select.Where(a => a.Title.EndsWith(a.Title + 1)).ToList()); | ||||
| 			list.Add(select.Where(a => a.Title.EndsWith(a.Type.Name)).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((a.`Title`) LIKE 'aaa%') | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((a.`Title`) LIKE concat(a.`Title`, '%')) | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((a.`Title`) LIKE concat(concat(a.`Title`, 1), '%')) | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type | ||||
| 			//WHERE((a.`Title`) LIKE concat(a__Type.`Name`, '%')) | ||||
| 			list.Add(select.Where(a => (a.Title + "aaa").EndsWith("aaa")).ToList()); | ||||
| 			list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Title)).ToList()); | ||||
| 			list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Title + 1)).ToList()); | ||||
| 			list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Type.Name)).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((concat(a.`Title`, 'aaa')) LIKE 'aaa%') | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((concat(a.`Title`, 'aaa')) LIKE concat(a.`Title`, '%')) | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((concat(a.`Title`, 'aaa')) LIKE concat(concat(a.`Title`, 1), '%')) | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type | ||||
| 			//WHERE((concat(a.`Title`, 'aaa')) LIKE concat(a__Type.`Name`, '%')) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Contains() { | ||||
| 			var list = new List<object>(); | ||||
| 			list.Add(select.Where(a => a.Title.Contains("aaa")).ToList()); | ||||
| 			list.Add(select.Where(a => a.Title.Contains(a.Title)).ToList()); | ||||
| 			list.Add(select.Where(a => a.Title.Contains(a.Title + 1)).ToList()); | ||||
| 			list.Add(select.Where(a => a.Title.Contains(a.Type.Name)).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((a.`Title`) LIKE '%aaa%') | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((a.`Title`) LIKE concat('%', a.`Title`, '%')) | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((a.`Title`) LIKE concat('%', a.`Title` +1, '%')) | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type | ||||
| 			//WHERE((a.`Title`) LIKE concat('%', a__Type.`Name`, '%')) | ||||
| 			list.Add(select.Where(a => (a.Title + "aaa").Contains("aaa")).ToList()); | ||||
| 			list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title)).ToList()); | ||||
| 			list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title + 1)).ToList()); | ||||
| 			list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Type.Name)).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((concat(a.`Title`, 'aaa')) LIKE '%aaa%') | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a.`Title`, '%')) | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', concat(a.`Title`, 1), '%')) | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type | ||||
| 			//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`, '%')) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ToLower() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.Title.ToLower() == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.ToLower() == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.ToLower() == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.ToLower() == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE(lower(a.`Title`) = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE(lower(a.`Title`) = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE(lower(a.`Title`) = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type | ||||
| 			//WHERE(lower(a.`Title`) = a__Type.`Name`); | ||||
| 			data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE(lower(concat(lower(a.`Title`), 'aaa')) = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE(lower(concat(lower(a.`Title`), 'aaa')) = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5 | ||||
| 			//FROM `tb_topic` a | ||||
| 			//WHERE(lower(concat(lower(a.`Title`), 'aaa')) = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type | ||||
| 			//WHERE(lower(concat(lower(a.`Title`), 'aaa')) = a__Type.`Name`) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void ToUpper() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.Title.ToUpper() == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.ToUpper() == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.ToUpper() == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.ToUpper() == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (upper(a.`Title`) = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (upper(a.`Title`) = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (upper(a.`Title`) = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (upper(a.`Title`) = a__Type.`Name`); | ||||
| 			data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (upper(concat(upper(a.`Title`), 'aaa')) = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (upper(concat(upper(a.`Title`), 'aaa')) = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (upper(concat(upper(a.`Title`), 'aaa')) = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (upper(concat(upper(a.`Title`), 'aaa')) = a__Type.`Name`) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Substring() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.Title.Substring(0) == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.Substring(0) == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.Substring(0) == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.Substring(0) == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (substr(a.`Title`, 1) = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (substr(a.`Title`, 1) = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (substr(a.`Title`, 1) = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (substr(a.`Title`, 1) = a__Type.`Name`); | ||||
| 			data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(a.Title.Length) == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(0, a.Title.Length) == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(0, 3) == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(1, 2) == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), char_length(a.`Title`) + 1) = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 1, char_length(a.`Title`)) = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 1, 3) = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 2, 2) = a__Type.`Name`) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Length() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.Title.Length == 0).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.Length == 1).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.Length == a.Title.Length + 1).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.Length == a.Type.Name.Length).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (char_length(a.`Title`) = 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (char_length(a.`Title`) = 1); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (char_length(a.`Title`) = char_length(a.`Title`) + 1); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (char_length(a.`Title`) = char_length(a__Type.`Name`)); | ||||
| 			data.Add(select.Where(a => (a.Title + "aaa").Length == 0).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title + "aaa").Length == 1).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title + "aaa").Length == a.Title.Length + 1).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title + "aaa").Length == a.Type.Name.Length).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (char_length(concat(a.`Title`, 'aaa')) = 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (char_length(concat(a.`Title`, 'aaa')) = 1); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (char_length(concat(a.`Title`, 'aaa')) = char_length(a.`Title`) + 1); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (char_length(concat(a.`Title`, 'aaa')) = char_length(a__Type.`Name`)) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void IndexOf() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.Title.IndexOf("aaa") == -1).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == -1).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == (a.Title.Length + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == a.Type.Name.Length + 1).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((locate(a.`Title`, 'aaa') - 1) = -1); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = -1); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = char_length(a.`Title`) + 1); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = char_length(a__Type.`Name`) + 1); | ||||
| 			data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa") == -1).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == -1).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == (a.Title.Length + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == a.Type.Name.Length + 1).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa') - 1) = -1); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = -1); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = char_length(a.`Title`) + 1); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = char_length(a__Type.`Name`) + 1) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void PadLeft() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (lpad(a.`Title`, 10, 'a') = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (lpad(a.`Title`, 10, 'a') = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (lpad(a.`Title`, 10, 'a') = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (lpad(a.`Title`, 10, 'a') = a__Type.`Name`); | ||||
| 			data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a__Type.`Name`) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void PadRight() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.Title.PadRight(10, 'a') == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.PadRight(10, 'a') == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.PadRight(10, 'a') == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.PadRight(10, 'a') == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (rpad(a.`Title`, 10, 'a') = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (rpad(a.`Title`, 10, 'a') = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (rpad(a.`Title`, 10, 'a') = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (rpad(a.`Title`, 10, 'a') = a__Type.`Name`); | ||||
| 			data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a__Type.`Name`) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Trim() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.Title.Trim() == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.Trim('a') == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.Trim('a', 'b') == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.Trim('a', 'b', 'c') == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim(a.`Title`) = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim('a' from a.`Title`) = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim('b' from trim('a' from a.`Title`)) = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (trim('c' from trim('b' from trim('a' from a.`Title`))) = a__Type.`Name`); | ||||
| 			data.Add(select.Where(a => (a.Title.Trim() + "aaa").Trim() == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.Trim('a') + "aaa").Trim('a') == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.Trim('a', 'b') + "aaa").Trim('a', 'b') == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.Trim('a', 'b', 'c') + "aaa").Trim('a', 'b', 'c') == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim(concat(trim(a.`Title`), 'aaa')) = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim('a' from concat(trim('a' from a.`Title`), 'aaa')) = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim('b' from trim('a' from concat(trim('b' from trim('a' from a.`Title`)), 'aaa'))) = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (trim('c' from trim('b' from trim('a' from concat(trim('c' from trim('b' from trim('a' from a.`Title`))), 'aaa')))) = a__Type.`Name`) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TrimStart() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.Title.TrimStart() == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.TrimStart('a') == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.TrimStart('a', 'b') == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.TrimStart('a', 'b', 'c') == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (ltrim(a.`Title`) = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim(trailing 'a' from trim(leading 'a' from a.`Title`)) = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))) = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))))) = a__Type.`Name`); | ||||
| 			data.Add(select.Where(a => (a.Title.TrimStart() + "aaa").TrimStart() == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.TrimStart('a') + "aaa").TrimStart('a') == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.TrimStart('a', 'b') + "aaa").TrimStart('a', 'b') == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.TrimStart('a', 'b', 'c') + "aaa").TrimStart('a', 'b', 'c') == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (ltrim(concat(ltrim(a.`Title`), 'aaa')) = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'a' from trim(leading 'a' from a.`Title`)), 'aaa'))) = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))), 'aaa'))))) = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))))), 'aaa'))))))) = a__Type.`Name`) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TrimEnd() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.Title.TrimEnd() == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.TrimEnd('a') == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.TrimEnd('a', 'b') == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (rtrim(a.`Title`) = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim(trailing 'a' from a.`Title`) = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim(trailing 'b' from trim(trailing 'a' from a.`Title`)) = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from a.`Title`))) = a__Type.`Name`); | ||||
| 			data.Add(select.Where(a => (a.Title.TrimEnd() + "aaa").TrimEnd() == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.TrimEnd('a') + "aaa").TrimEnd('a') == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.TrimEnd('a', 'b') + "aaa").TrimEnd('a', 'b') == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.TrimEnd('a', 'b', 'c') + "aaa").TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (rtrim(concat(rtrim(a.`Title`), 'aaa')) = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim(trailing 'a' from concat(trim(trailing 'a' from a.`Title`), 'aaa')) = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (trim(trailing 'b' from trim(trailing 'a' from concat(trim(trailing 'b' from trim(trailing 'a' from a.`Title`)), 'aaa'))) = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from concat(trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from a.`Title`))), 'aaa')))) = a__Type.`Name`) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Replace() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.Title.Replace("a", "b") == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c") == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c").Replace("c", "a") == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c").Replace(a.Type.Name, "a") == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (replace(a.`Title`, 'a', 'b') = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (replace(replace(a.`Title`, 'a', 'b'), 'b', 'c') = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'c', 'a') = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), a__Type.`Name`, 'a') = a__Type.`Name`); | ||||
| 			data.Add(select.Where(a => (a.Title.Replace("a", "b") + "aaa").TrimEnd() == "aaa").ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c") + "aaa").TrimEnd('a') == a.Title).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c").Replace("c", "a") + "aaa").TrimEnd('a', 'b') == (a.Title + 1)).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c").Replace(a.Type.Name, "a") + "aaa").TrimEnd('a', 'b', 'c') == a.Type.Name).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (concat(replace(a.`Title`, 'a', 'b'), 'aaa') = 'aaa'); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (concat(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'aaa') = a.`Title`); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (concat(replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'c', 'a'), 'aaa') = concat(a.`Title`, 1)); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (concat(replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), a__Type.`Name`, 'a'), 'aaa') = a__Type.`Name`) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void CompareTo() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.Title.CompareTo(a.Title) == 0).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.CompareTo(a.Title) > 0).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.CompareTo(a.Title + 1) == 0).ToList()); | ||||
| 			data.Add(select.Where(a => a.Title.CompareTo(a.Title + a.Type.Name) == 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (strcmp(a.`Title`, a.`Title`) = 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (strcmp(a.`Title`, a.`Title`) > 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (strcmp(a.`Title`, concat(a.`Title`, 1)) = 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (strcmp(a.`Title`, concat(a.`Title`, a__Type.`Name`)) = 0); | ||||
| 			data.Add(select.Where(a => (a.Title + "aaa").CompareTo("aaa") == 0).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Title) > 0).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Title + 1) == 0).ToList()); | ||||
| 			data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Type.Name) == 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (strcmp(concat(a.`Title`, 'aaa'), 'aaa') = 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (strcmp(concat(a.`Title`, 'aaa'), a.`Title`) > 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (strcmp(concat(a.`Title`, 'aaa'), concat(a.`Title`, 1)) = 0); | ||||
|  | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8  | ||||
| 			//FROM `tb_topic` a, `TestTypeInfo` a__Type  | ||||
| 			//WHERE (strcmp(concat(a.`Title`, 'aaa'), a__Type.`Name`) = 0) | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void string_IsNullOrEmpty() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => string.IsNullOrEmpty(a.Title)).ToList()); | ||||
| 			data.Add(select.Where(a => string.IsNullOrEmpty(a.Title) == false).ToList()); | ||||
| 			data.Add(select.Where(a => !string.IsNullOrEmpty(a.Title)).ToList()); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,260 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnectorExpression { | ||||
| 	public class TimeSpanTest { | ||||
|  | ||||
| 		ISelect<Topic> select => g.mysql.Select<Topic>(); | ||||
|  | ||||
| 		[Table(Name = "tb_topic")] | ||||
| 		class Topic { | ||||
| 			[Column(IsIdentity = true, IsPrimary = true)] | ||||
| 			public int Id { get; set; } | ||||
| 			public int Clicks { get; set; } | ||||
| 			public int TypeGuid { get; set; } | ||||
| 			public TestTypeInfo Type { get; set; } | ||||
| 			public string Title { get; set; } | ||||
| 			public DateTime CreateTime { get; set; } | ||||
| 		} | ||||
| 		class TestTypeInfo { | ||||
| 			public int Guid { get; set; } | ||||
| 			public int ParentId { get; set; } | ||||
| 			public TestTypeParentInfo Parent { get; set; } | ||||
| 			public string Name { get; set; } | ||||
| 		} | ||||
| 		class TestTypeParentInfo { | ||||
| 			public int Id { get; set; } | ||||
| 			public string Name { get; set; } | ||||
|  | ||||
| 			public List<TestTypeInfo> Types { get; set; } | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Zero() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay > TimeSpan.Zero).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void MinValue() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay > TimeSpan.MinValue).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) > -922337203685477580) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void MaxValue() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay < TimeSpan.MaxValue).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) < 922337203685477580) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Days() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.Days == 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 86400000000) = 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Hours() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.Hours > 0).ToSql()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 3600000000) mod 24 > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Milliseconds() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.Milliseconds > 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 1000 mod 1000) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Minutes() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.Minutes > 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 60000000 mod 60) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Seconds() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.Seconds > 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 1000000 mod 60) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Ticks() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.Ticks > 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) * 10) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TotalDays() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalDays > 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 86400000000) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TotalHours() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalHours > 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 3600000000) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TotalMilliseconds() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalMilliseconds > 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 1000) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TotalMinutes() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalMinutes > 0).ToSql()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 60000000) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TotalSeconds() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalSeconds > 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 1000000) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Add() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.Add(TimeSpan.FromDays(1)) > TimeSpan.Zero).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) + (1 * 86400000000)) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void Subtract() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.Subtract(TimeSpan.FromDays(1)) > TimeSpan.Zero).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) - (1 * 86400000000)) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void CompareTo() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.CompareTo(TimeSpan.FromDays(1)) > 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) - ((1 * 86400000000))) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void this_Equals() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.Equals(TimeSpan.FromDays(1))).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void this_ToString() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => a.CreateTime.TimeOfDay.ToString() == "ssss").ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (date_format(date_add(cast('0001/1/1 0:00:00' as datetime), interval (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) microsecond), '%Y-%m-%d %H:%i:%s.%f') = 'ssss') | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void TimeSpan_Compare() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => TimeSpan.Compare(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1)) > 0).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) - ((1 * 86400000000))) > 0) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TimeSpan_Equals() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1))).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TimeSpan_FromDays() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1))).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000))) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TimeSpan_FromHours() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromHours(1))).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 3600000000))) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TimeSpan_FromMilliseconds() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromMilliseconds(1))).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 1000))) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TimeSpan_FromMinutes() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromMinutes(1))).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 60000000))) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TimeSpan_FromSeconds() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromSeconds(1))).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 1000000))) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TimeSpan_FromTicks() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromTicks(1))).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 / 10))) | ||||
| 		} | ||||
| 		[Fact] | ||||
| 		public void TimeSpan_Parse() { | ||||
| 			var data = new List<object>(); | ||||
| 			data.Add(select.Where(a => TimeSpan.Parse(a.CreateTime.TimeOfDay.ToString()) > TimeSpan.Zero).ToList()); | ||||
| 			//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5  | ||||
| 			//FROM `tb_topic` a  | ||||
| 			//WHERE (cast(date_format(date_add(cast('0001/1/1 0:00:00' as datetime), interval (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) microsecond), '%Y-%m-%d %H:%i:%s.%f') as signed) > 0) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,21 @@ | ||||
| using FreeSql.DataAnnotations; | ||||
| using System; | ||||
| using Xunit; | ||||
|  | ||||
| namespace FreeSql.Tests.MySqlConnector { | ||||
| 	public class MySqlDbFirstTest { | ||||
| 		[Fact] | ||||
| 		public void GetDatabases() { | ||||
|  | ||||
| 			var t1 = g.mysql.DbFirst.GetDatabases(); | ||||
|  | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
| 		public void GetTablesByDatabase() { | ||||
|  | ||||
| 			var t2 = g.mysql.DbFirst.GetTablesByDatabase(g.mysql.DbFirst.GetDatabases()[0]); | ||||
|  | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										22
									
								
								FreeSql.Tests.Provider.MySqlConnector/g.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								FreeSql.Tests.Provider.MySqlConnector/g.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Diagnostics; | ||||
| using System.Text; | ||||
|  | ||||
|  | ||||
| public class g { | ||||
|  | ||||
| 	static Lazy<IFreeSql> mysqlLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder() | ||||
| 		.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd_mysqlconnector;Charset=utf8;SslMode=none;Max pool size=10") | ||||
| 		.UseAutoSyncStructure(true) | ||||
| 		.UseMonitorCommand( | ||||
| 			cmd => { | ||||
| 				Trace.WriteLine(cmd.CommandText); | ||||
| 			}, //监听SQL命令对象,在执行前 | ||||
| 			(cmd, traceLog) => { | ||||
| 				Console.WriteLine(traceLog); | ||||
| 			}) //监听SQL命令对象,在执行后 | ||||
| 		.UseLazyLoading(true) | ||||
| 		.Build()); | ||||
| 	public static IFreeSql mysql => mysqlLazy.Value; | ||||
| } | ||||
| @@ -40,8 +40,8 @@ namespace FreeSql.Tests.MySql { | ||||
| 			var sql = delete.Where(a => a.Id == 1).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM `tb_topic` WHERE (`Id` = 1)", sql); | ||||
|  | ||||
| 			sql = delete.Where("id = ?id", new { id = 1 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM `tb_topic` WHERE (id = ?id)", sql); | ||||
| 			sql = delete.Where("id = @id", new { id = 1 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM `tb_topic` WHERE (id = @id)", sql); | ||||
|  | ||||
| 			var item = new Topic { Id = 1, Title = "newtitle" }; | ||||
| 			sql = delete.Where(item).ToSql().Replace("\r\n", ""); | ||||
|   | ||||
| @@ -279,7 +279,7 @@ namespace FreeSql.Tests.MySql { | ||||
| 			var sql2222 = select.Where(a => | ||||
| 				select.Where(b => b.Id == a.Id && | ||||
| 					select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id) | ||||
| 					.Offset(a.Id) | ||||
| 					//.Offset(a.Id) | ||||
| 					.Any() | ||||
| 				).Any(c => c.Id == a.Id + 10) | ||||
| 			); | ||||
| @@ -697,7 +697,7 @@ namespace FreeSql.Tests.MySql { | ||||
| 			sql2222 = select.Where(a => | ||||
| 				select.Where(b => b.Id == a.Id && select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id) | ||||
|  | ||||
| 				.Offset(a.Id) | ||||
| 				//.Offset(a.Id) | ||||
|  | ||||
| 				.Any() | ||||
| 				).Any() | ||||
|   | ||||
| @@ -41,8 +41,8 @@ namespace FreeSql.Tests.MySqlExpression { | ||||
| 		public void Equals__() { | ||||
| 			var list = new List<object>(); | ||||
| 			list.Add(select.Where(a => a.Title.Equals("aaa")).ToList()); | ||||
| 			list.Add(g.sqlite.Select<TestEqualsGuid>().Where(a => a.id.Equals(Guid.Empty)).ToList()); | ||||
| 			list.Add(g.sqlite.Select<TestEqualsGuid>().Where(a => a.IsDeleted.Equals(false)).ToList()); | ||||
| 			list.Add(g.mysql.Select<TestEqualsGuid>().Where(a => a.id.Equals(Guid.Empty)).ToList()); | ||||
| 			list.Add(g.mysql.Select<TestEqualsGuid>().Where(a => a.IsDeleted.Equals(false)).ToList()); | ||||
| 		} | ||||
|  | ||||
| 		[Fact] | ||||
|   | ||||
| @@ -40,8 +40,8 @@ namespace FreeSql.Tests.Oracle { | ||||
| 			var sql = delete.Where(a => a.Id == 1).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM \"TB_TOPIC22211\" WHERE (\"ID\" = 1)", sql); | ||||
|  | ||||
| 			sql = delete.Where("id = ?id", new { id = 1 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM \"TB_TOPIC22211\" WHERE (id = ?id)", sql); | ||||
| 			sql = delete.Where("id = :id", new { id = 1 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM \"TB_TOPIC22211\" WHERE (id = :id)", sql); | ||||
|  | ||||
| 			var item = new Topic { Id = 1, Title = "newtitle" }; | ||||
| 			sql = delete.Where(item).ToSql().Replace("\r\n", ""); | ||||
|   | ||||
| @@ -174,7 +174,7 @@ namespace FreeSql.Tests.Oracle { | ||||
| 			var sql2222 = select.Where(a => | ||||
| 				select.Where(b => b.Id == a.Id && | ||||
| 					select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id) | ||||
| 					.Offset(a.Id) | ||||
| 					//.Offset(a.Id) | ||||
| 					.Any() | ||||
| 				).Any(c => c.Id == a.Id + 10) | ||||
| 			); | ||||
| @@ -591,7 +591,7 @@ namespace FreeSql.Tests.Oracle { | ||||
| 			sql2222 = select.Where(a => | ||||
| 				select.Where(b => b.Id == a.Id && select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id) | ||||
|  | ||||
| 				.Offset(a.Id) | ||||
| 				//.Offset(a.Id) | ||||
|  | ||||
| 				.Any() | ||||
| 				).Any() | ||||
|   | ||||
| @@ -40,8 +40,8 @@ namespace FreeSql.Tests.PostgreSQL { | ||||
| 			var sql = delete.Where(a => a.Id == 1).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM \"tb_topic_del\" WHERE (\"id\" = 1)", sql); | ||||
|  | ||||
| 			sql = delete.Where("id = ?id", new { id = 1 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM \"tb_topic_del\" WHERE (id = ?id)", sql); | ||||
| 			sql = delete.Where("id = @id", new { id = 1 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM \"tb_topic_del\" WHERE (id = @id)", sql); | ||||
|  | ||||
| 			var item = new Topic { Id = 1, Title = "newtitle" }; | ||||
| 			sql = delete.Where(item).ToSql().Replace("\r\n", ""); | ||||
|   | ||||
| @@ -244,7 +244,7 @@ namespace FreeSql.Tests.PostgreSQL { | ||||
| 			var sql2222 = select.Where(a => | ||||
| 				select.Where(b => b.Id == a.Id && | ||||
| 					select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id) | ||||
| 					.Offset(a.Id) | ||||
| 					//.Offset(a.Id) | ||||
| 					.Any() | ||||
| 				).Any(c => c.Id == a.Id + 10) | ||||
| 			); | ||||
| @@ -663,7 +663,7 @@ namespace FreeSql.Tests.PostgreSQL { | ||||
| 			sql2222 = select.Where(a => | ||||
| 				select.Where(b => b.Id == a.Id && select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id) | ||||
|  | ||||
| 				.Offset(a.Id) | ||||
| 				//.Offset(a.Id) | ||||
|  | ||||
| 				.Any() | ||||
| 				).Any() | ||||
|   | ||||
| @@ -49,8 +49,8 @@ namespace FreeSql.Tests.SqlServer { | ||||
| 			var sql = delete.Where(a => a.Id == 1).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM [tb_topic22211] WHERE ([Id] = 1)", sql); | ||||
|  | ||||
| 			sql = delete.Where("id = ?id", new { id = 1 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM [tb_topic22211] WHERE (id = ?id)", sql); | ||||
| 			sql = delete.Where("id = @id", new { id = 1 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM [tb_topic22211] WHERE (id = @id)", sql); | ||||
|  | ||||
| 			var item = new Topic { Id = 1, Title = "newtitle" }; | ||||
| 			sql = delete.Where(item).ToSql().Replace("\r\n", ""); | ||||
|   | ||||
| @@ -176,7 +176,7 @@ namespace FreeSql.Tests.SqlServer { | ||||
| 			var sql2222 = select.Where(a => | ||||
| 				select.Where(b => b.Id == a.Id && | ||||
| 					select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id) | ||||
| 					.Offset(a.Id) | ||||
| 					//.Offset(a.Id) | ||||
| 					.Any() | ||||
| 				).Any(c => c.Id == a.Id + 10) | ||||
| 			); | ||||
| @@ -594,7 +594,7 @@ namespace FreeSql.Tests.SqlServer { | ||||
| 			sql2222 = select.Where(a => | ||||
| 				select.Where(b => b.Id == a.Id && select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id) | ||||
|  | ||||
| 				.Offset(a.Id) | ||||
| 				//.Offset(a.Id) | ||||
|  | ||||
| 				.Any() | ||||
| 				).Any() | ||||
|   | ||||
| @@ -40,8 +40,8 @@ namespace FreeSql.Tests.Sqlite { | ||||
| 			var sql = delete.Where(a => a.Id == 1).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM \"tb_topic22211\" WHERE (\"Id\" = 1)", sql); | ||||
|  | ||||
| 			sql = delete.Where("id = ?id", new { id = 1 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM \"tb_topic22211\" WHERE (id = ?id)", sql); | ||||
| 			sql = delete.Where("id = @id", new { id = 1 }).ToSql().Replace("\r\n", ""); | ||||
| 			Assert.Equal("DELETE FROM \"tb_topic22211\" WHERE (id = @id)", sql); | ||||
|  | ||||
| 			var item = new Topic { Id = 1, Title = "newtitle" }; | ||||
| 			sql = delete.Where(item).ToSql().Replace("\r\n", ""); | ||||
|   | ||||
| @@ -185,7 +185,7 @@ namespace FreeSql.Tests.Sqlite { | ||||
| 			var sql2222 = select.Where(a => | ||||
| 				select.Where(b => b.Id == a.Id && | ||||
| 					select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id) | ||||
| 					.Offset(a.Id) | ||||
| 					//.Offset(a.Id) | ||||
| 					.Any() | ||||
| 				).Any(c => c.Id == a.Id + 10) | ||||
| 			); | ||||
| @@ -537,7 +537,7 @@ namespace FreeSql.Tests.Sqlite { | ||||
| 			sql2222 = select.Where(a => | ||||
| 				select.Where(b => b.Id == a.Id && select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id) | ||||
|  | ||||
| 				.Offset(a.Id) | ||||
| 				//.Offset(a.Id) | ||||
|  | ||||
| 				.Any() | ||||
| 				).Any() | ||||
|   | ||||
| @@ -568,7 +568,7 @@ namespace FreeSql.Tests { | ||||
| 			var sql2222 = select.Where(a =>  | ||||
| 				select.Where(b => b.Id == a.Id &&  | ||||
| 					select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id) | ||||
| 					.Offset(a.Id) | ||||
| 					//.Offset(a.Id) | ||||
| 					.Any() | ||||
| 				).Any() | ||||
| 			).ToList(); | ||||
|   | ||||
							
								
								
									
										14
									
								
								FreeSql.sln
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								FreeSql.sln
									
									
									
									
									
								
							| @@ -42,6 +42,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Extensions.LazyLoad | ||||
| EndProject | ||||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.MySqlConnector", "Providers\FreeSql.Provider.MySqlConnector\FreeSql.Provider.MySqlConnector.csproj", "{D2A41321-5E84-410B-B25C-3AA122D4CA27}" | ||||
| EndProject | ||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeSql.Tests.Provider.MySqlConnector", "FreeSql.Tests.Provider.MySqlConnector\FreeSql.Tests.Provider.MySqlConnector.csproj", "{D113CDFB-FB97-482B-8A00-058E715B624A}" | ||||
| EndProject | ||||
| Global | ||||
| 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||
| 		Debug|Any CPU = Debug|Any CPU | ||||
| @@ -220,6 +222,18 @@ Global | ||||
| 		{D2A41321-5E84-410B-B25C-3AA122D4CA27}.Release|x64.Build.0 = Release|Any CPU | ||||
| 		{D2A41321-5E84-410B-B25C-3AA122D4CA27}.Release|x86.ActiveCfg = Release|Any CPU | ||||
| 		{D2A41321-5E84-410B-B25C-3AA122D4CA27}.Release|x86.Build.0 = Release|Any CPU | ||||
| 		{D113CDFB-FB97-482B-8A00-058E715B624A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||
| 		{D113CDFB-FB97-482B-8A00-058E715B624A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||
| 		{D113CDFB-FB97-482B-8A00-058E715B624A}.Debug|x64.ActiveCfg = Debug|Any CPU | ||||
| 		{D113CDFB-FB97-482B-8A00-058E715B624A}.Debug|x64.Build.0 = Debug|Any CPU | ||||
| 		{D113CDFB-FB97-482B-8A00-058E715B624A}.Debug|x86.ActiveCfg = Debug|Any CPU | ||||
| 		{D113CDFB-FB97-482B-8A00-058E715B624A}.Debug|x86.Build.0 = Debug|Any CPU | ||||
| 		{D113CDFB-FB97-482B-8A00-058E715B624A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||
| 		{D113CDFB-FB97-482B-8A00-058E715B624A}.Release|Any CPU.Build.0 = Release|Any CPU | ||||
| 		{D113CDFB-FB97-482B-8A00-058E715B624A}.Release|x64.ActiveCfg = Release|Any CPU | ||||
| 		{D113CDFB-FB97-482B-8A00-058E715B624A}.Release|x64.Build.0 = Release|Any CPU | ||||
| 		{D113CDFB-FB97-482B-8A00-058E715B624A}.Release|x86.ActiveCfg = Release|Any CPU | ||||
| 		{D113CDFB-FB97-482B-8A00-058E715B624A}.Release|x86.Build.0 = Release|Any CPU | ||||
| 	EndGlobalSection | ||||
| 	GlobalSection(SolutionProperties) = preSolution | ||||
| 		HideSolutionNode = FALSE | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| 	<PropertyGroup> | ||||
| 		<TargetFrameworks>netstandard2.0;net45</TargetFrameworks> | ||||
| 		<Version>0.6.5</Version> | ||||
| 		<Version>0.6.6</Version> | ||||
| 		<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||||
| 		<Authors>YeXiangQin</Authors> | ||||
| 		<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description> | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| 	<PropertyGroup> | ||||
| 		<TargetFrameworks>netstandard2.0;net452</TargetFrameworks> | ||||
| 		<Version>0.6.5</Version> | ||||
| 		<Version>0.6.6</Version> | ||||
| 		<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||||
| 		<Authors>YeXiangQin</Authors> | ||||
| 		<Description>FreeSql 数据库实现,基于 MySql 5.6</Description> | ||||
|   | ||||
| @@ -1,6 +0,0 @@ | ||||
| using System; | ||||
|  | ||||
| namespace FreeSql.Provider.MySqlConnector { | ||||
| 	public class Class1 { | ||||
| 	} | ||||
| } | ||||
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| 	<PropertyGroup> | ||||
| 		<TargetFrameworks>netstandard2.0;net45</TargetFrameworks> | ||||
| 		<Version>0.6.5</Version> | ||||
| 		<Version>0.6.6</Version> | ||||
| 		<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||||
| 		<Authors>YeXiangQin</Authors> | ||||
| 		<Description>FreeSql 数据库实现,基于 MySql 5.6</Description> | ||||
| @@ -23,6 +23,11 @@ | ||||
|  | ||||
| 	<ItemGroup> | ||||
| 		<Compile Include="../FreeSql.Provider.MySql/**/*.cs" Exclude="../FreeSql.Provider.MySql/obj/**/*" /> | ||||
| 		<None Include="../FreeSql.Provider.MySql/MySqlUtils.cs" /> | ||||
| 	</ItemGroup> | ||||
|  | ||||
| 	<ItemGroup> | ||||
| 	  <Compile Remove="..\FreeSql.Provider.MySql\MySqlUtils.cs" /> | ||||
| 	</ItemGroup> | ||||
| 	 | ||||
| 	<ItemGroup> | ||||
|   | ||||
							
								
								
									
										111
									
								
								Providers/FreeSql.Provider.MySqlConnector/MySqlConnectorUtils.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								Providers/FreeSql.Provider.MySqlConnector/MySqlConnectorUtils.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,111 @@ | ||||
| using FreeSql.Internal; | ||||
| using FreeSql.Internal.Model; | ||||
| using MySql.Data.MySqlClient; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Data.Common; | ||||
| using System.Linq; | ||||
| using System.Linq.Expressions; | ||||
| using System.Reflection; | ||||
| using System.Text; | ||||
|  | ||||
| namespace FreeSql.MySql { | ||||
|  | ||||
| 	class MySqlUtils : CommonUtils { | ||||
| 		public MySqlUtils(IFreeSql orm) : base(orm) { | ||||
| 		} | ||||
|  | ||||
| 		public override DbParameter AppendParamter(List<DbParameter> _params, string parameterName, Type type, object value) { | ||||
| 			if (string.IsNullOrEmpty(parameterName)) parameterName = $"p_{_params?.Count}"; | ||||
| 			var ret = new MySqlParameter { ParameterName = QuoteParamterName(parameterName), Value = value }; | ||||
| 			var tp = _orm.CodeFirst.GetDbInfo(type)?.type; | ||||
| 			if (tp != null) { | ||||
| 				if ((MySqlDbType)tp.Value == MySqlDbType.Geometry) { | ||||
| 					ret.MySqlDbType = MySqlDbType.Text; | ||||
| 					if (value != null) ret.Value = (value as MygisGeometry).AsText(); | ||||
| 				} else { | ||||
| 					ret.MySqlDbType = (MySqlDbType)tp.Value; | ||||
| 					if (ret.MySqlDbType == MySqlDbType.Enum && value != null) | ||||
| 						ret.Value = (long)Convert.ChangeType(value, typeof(long)) + 1; | ||||
| 				} | ||||
| 			} | ||||
| 			_params?.Add(ret); | ||||
| 			return ret; | ||||
| 		} | ||||
|  | ||||
| 		public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => | ||||
| 			Utils.GetDbParamtersByObject<MySqlParameter>(sql, obj, "@", (name, type, value) => { | ||||
| 				var ret = new MySqlParameter { ParameterName = $"@{name}", Value = value }; | ||||
| 				var tp = _orm.CodeFirst.GetDbInfo(type)?.type; | ||||
| 				if (tp != null) { | ||||
| 					if ((MySqlDbType)tp.Value == MySqlDbType.Geometry) { | ||||
| 						ret.MySqlDbType = MySqlDbType.Text; | ||||
| 						if (value != null) ret.Value = (value as MygisGeometry).AsText(); | ||||
| 					} else { | ||||
| 						ret.MySqlDbType = (MySqlDbType)tp.Value; | ||||
| 						if (ret.MySqlDbType == MySqlDbType.Enum && value != null) | ||||
| 							ret.Value = (long)Convert.ChangeType(value, typeof(long)) + 1; | ||||
| 					} | ||||
| 				} | ||||
| 				return ret; | ||||
| 			}); | ||||
|  | ||||
| 		public override string FormatSql(string sql, params object[] args) => sql?.FormatMySql(args); | ||||
| 		public override string QuoteSqlName(string name) { | ||||
| 			var nametrim = name.Trim(); | ||||
| 			if (nametrim.StartsWith("(") && nametrim.EndsWith(")")) | ||||
| 				return nametrim; //原生SQL | ||||
| 			return $"`{nametrim.Trim('`').Replace(".", "`.`")}`"; | ||||
| 		} | ||||
| 		public override string TrimQuoteSqlName(string name) { | ||||
| 			var nametrim = name.Trim(); | ||||
| 			if (nametrim.StartsWith("(") && nametrim.EndsWith(")")) | ||||
| 				return nametrim; //原生SQL | ||||
| 			return $"{nametrim.Trim('`').Replace("`.`", ".").Replace(".`", ".")}"; | ||||
| 		} | ||||
| 		public override string QuoteParamterName(string name) => $"@{(_orm.CodeFirst.IsSyncStructureToLower ? name.ToLower() : name)}"; | ||||
| 		public override string IsNull(string sql, object value) => $"ifnull({sql}, {value})"; | ||||
| 		public override string StringConcat(string[] objs, Type[] types) => $"concat({string.Join(", ", objs)})"; | ||||
| 		public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}"; | ||||
| 		public override string QuoteWriteParamter(Type type, string paramterName) { | ||||
| 			switch (type.FullName) { | ||||
| 				case "MygisPoint": | ||||
| 				case "MygisLineString":  | ||||
| 				case "MygisPolygon":  | ||||
| 				case "MygisMultiPoint":  | ||||
| 				case "MygisMultiLineString": | ||||
| 				case "MygisMultiPolygon": return $"ST_GeomFromText({paramterName})"; | ||||
| 			} | ||||
| 			return paramterName; | ||||
| 		} | ||||
|  | ||||
| 		public override string QuoteReadColumn(Type type, string columnName) { | ||||
| 			switch (type.FullName) { | ||||
| 				case "MygisPoint": | ||||
| 				case "MygisLineString": | ||||
| 				case "MygisPolygon": | ||||
| 				case "MygisMultiPoint": | ||||
| 				case "MygisMultiLineString": | ||||
| 				case "MygisMultiPolygon": return $"AsText({columnName})"; | ||||
| 			} | ||||
| 			return columnName; | ||||
| 		} | ||||
|  | ||||
| 		public override string GetNoneParamaterSqlValue(List<DbParameter> specialParams, Type type, object value) { | ||||
| 			if (value == null) return "NULL"; | ||||
| 			if (type == typeof(byte[])) { | ||||
| 				var bytes = value as byte[]; | ||||
| 				var sb = new StringBuilder().Append("0x"); | ||||
| 				foreach (var vc in bytes) { | ||||
| 					if (vc < 10) sb.Append("0"); | ||||
| 					sb.Append(vc.ToString("X")); | ||||
| 				} | ||||
| 				return sb.ToString(); //val = Encoding.UTF8.GetString(val as byte[]); | ||||
| 			} else if (type == typeof(TimeSpan) || type == typeof(TimeSpan?)) { | ||||
| 				var ts = (TimeSpan)value; | ||||
| 				value = $"{Math.Floor(ts.TotalHours)}:{ts.Minutes}:{ts.Seconds}"; | ||||
| 			} | ||||
| 			return FormatSql("{0}", value, 1); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| 	<PropertyGroup> | ||||
| 		<TargetFrameworks>netstandard2.0;net45</TargetFrameworks> | ||||
| 		<Version>0.6.5</Version> | ||||
| 		<Version>0.6.6</Version> | ||||
| 		<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||||
| 		<Authors>YeXiangQin</Authors> | ||||
| 		<Description>FreeSql 数据库实现,基于 Oracle 11</Description> | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| 	<PropertyGroup> | ||||
| 		<TargetFrameworks>netstandard2.0;net45</TargetFrameworks> | ||||
| 		<Version>0.6.5</Version> | ||||
| 		<Version>0.6.6</Version> | ||||
| 		<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||||
| 		<Authors>YeXiangQin</Authors> | ||||
| 		<Description>FreeSql 数据库实现,基于 PostgreSQL 9.5</Description> | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| 	<PropertyGroup> | ||||
| 		<TargetFrameworks>netstandard2.0;net451</TargetFrameworks> | ||||
| 		<Version>0.6.5</Version> | ||||
| 		<Version>0.6.6</Version> | ||||
| 		<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||||
| 		<Authors>YeXiangQin</Authors> | ||||
| 		<Description>FreeSql 数据库实现,基于 SqlServer 2005+,并根据版本适配分页方法:row_number 或 offset fetch next</Description> | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| 	<PropertyGroup> | ||||
| 		<TargetFrameworks>netstandard2.0;net45</TargetFrameworks> | ||||
| 		<Version>0.6.5</Version> | ||||
| 		<Version>0.6.6</Version> | ||||
| 		<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||||
| 		<Authors>YeXiangQin</Authors> | ||||
| 		<Description>FreeSql 数据库实现,基于 Sqlite 3.0</Description> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 28810
					28810