mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 补充 MapType,Column.MapType 类型映射,可将 enum 映射为 int/string 等 #19 #42;
- 优化 PostgreSQL jsonb 类型使用习惯;
This commit is contained in:
		@@ -2,7 +2,7 @@ using FreeSql.DataAnnotations;
 | 
				
			|||||||
using System;
 | 
					using System;
 | 
				
			||||||
using Xunit;
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace FreeSql.Tests.MySql.MapType {
 | 
					namespace FreeSql.Tests.MySqlMapType {
 | 
				
			||||||
	public class BoolNullableTest {
 | 
						public class BoolNullableTest {
 | 
				
			||||||
		class BoolNullableMap {
 | 
							class BoolNullableMap {
 | 
				
			||||||
			public Guid id { get; set; }
 | 
								public Guid id { get; set; }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@ using FreeSql.DataAnnotations;
 | 
				
			|||||||
using System;
 | 
					using System;
 | 
				
			||||||
using Xunit;
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace FreeSql.Tests.MySql.MapType {
 | 
					namespace FreeSql.Tests.MySqlMapType {
 | 
				
			||||||
	public class BoolTest {
 | 
						public class BoolTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		class BoolMap {
 | 
							class BoolMap {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@ using System;
 | 
				
			|||||||
using System.Numerics;
 | 
					using System.Numerics;
 | 
				
			||||||
using Xunit;
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace FreeSql.Tests.MySql.MapType {
 | 
					namespace FreeSql.Tests.MySqlMapType {
 | 
				
			||||||
	public class EnumTest {
 | 
						public class EnumTest {
 | 
				
			||||||
		class EnumTestMap {
 | 
							class EnumTestMap {
 | 
				
			||||||
			public Guid id { get; set; }
 | 
								public Guid id { get; set; }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@ using System;
 | 
				
			|||||||
using System.Numerics;
 | 
					using System.Numerics;
 | 
				
			||||||
using Xunit;
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace FreeSql.Tests.MySql.MapType {
 | 
					namespace FreeSql.Tests.MySqlMapType {
 | 
				
			||||||
	public class ToStringTest {
 | 
						public class ToStringTest {
 | 
				
			||||||
		class ToStringMap {
 | 
							class ToStringMap {
 | 
				
			||||||
			public Guid id { get; set; }
 | 
								public Guid id { get; set; }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1562
									
								
								FreeSql.Tests/Oracle/MapType/BoolNullableTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1562
									
								
								FreeSql.Tests/Oracle/MapType/BoolNullableTest.cs
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1096
									
								
								FreeSql.Tests/Oracle/MapType/BoolTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1096
									
								
								FreeSql.Tests/Oracle/MapType/BoolTest.cs
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										254
									
								
								FreeSql.Tests/Oracle/MapType/EnumTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										254
									
								
								FreeSql.Tests/Oracle/MapType/EnumTest.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,254 @@
 | 
				
			|||||||
 | 
					using FreeSql.DataAnnotations;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Numerics;
 | 
				
			||||||
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace FreeSql.Tests.OracleMapType {
 | 
				
			||||||
 | 
						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.oracle;
 | 
				
			||||||
 | 
								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.oracle;
 | 
				
			||||||
 | 
								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.oracle;
 | 
				
			||||||
 | 
								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.oracle;
 | 
				
			||||||
 | 
								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());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										557
									
								
								FreeSql.Tests/Oracle/MapType/ToStringTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										557
									
								
								FreeSql.Tests/Oracle/MapType/ToStringTest.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,557 @@
 | 
				
			|||||||
 | 
					using FreeSql.DataAnnotations;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Numerics;
 | 
				
			||||||
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace FreeSql.Tests.OracleMapType {
 | 
				
			||||||
 | 
						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.oracle;
 | 
				
			||||||
 | 
								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.oracle;
 | 
				
			||||||
 | 
								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.oracle;
 | 
				
			||||||
 | 
								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.oracle;
 | 
				
			||||||
 | 
								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.oracle;
 | 
				
			||||||
 | 
								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.oracle;
 | 
				
			||||||
 | 
								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.oracle;
 | 
				
			||||||
 | 
								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.oracle;
 | 
				
			||||||
 | 
								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.oracle;
 | 
				
			||||||
 | 
								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.oracle;
 | 
				
			||||||
 | 
								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());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										1562
									
								
								FreeSql.Tests/PostgreSQL/MapType/BoolNullableTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1562
									
								
								FreeSql.Tests/PostgreSQL/MapType/BoolNullableTest.cs
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1096
									
								
								FreeSql.Tests/PostgreSQL/MapType/BoolTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1096
									
								
								FreeSql.Tests/PostgreSQL/MapType/BoolTest.cs
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										254
									
								
								FreeSql.Tests/PostgreSQL/MapType/EnumTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										254
									
								
								FreeSql.Tests/PostgreSQL/MapType/EnumTest.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,254 @@
 | 
				
			|||||||
 | 
					using FreeSql.DataAnnotations;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Numerics;
 | 
				
			||||||
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace FreeSql.Tests.PostgreSQLMapType {
 | 
				
			||||||
 | 
						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.pgsql;
 | 
				
			||||||
 | 
								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.pgsql;
 | 
				
			||||||
 | 
								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.pgsql;
 | 
				
			||||||
 | 
								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.pgsql;
 | 
				
			||||||
 | 
								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());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										424
									
								
								FreeSql.Tests/PostgreSQL/MapType/JTokenTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										424
									
								
								FreeSql.Tests/PostgreSQL/MapType/JTokenTest.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,424 @@
 | 
				
			|||||||
 | 
					using FreeSql.DataAnnotations;
 | 
				
			||||||
 | 
					using Newtonsoft.Json.Linq;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace FreeSql.Tests.PostgreSQLMapType {
 | 
				
			||||||
 | 
						public class JTokenTest {
 | 
				
			||||||
 | 
							class JTokenTestMap {
 | 
				
			||||||
 | 
								public Guid id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								[Column(MapType = typeof(JToken))]
 | 
				
			||||||
 | 
								public string string_to_jtoken { get; set; }
 | 
				
			||||||
 | 
								[Column(MapType = typeof(JArray))]
 | 
				
			||||||
 | 
								public string string_to_jarray { get; set; }
 | 
				
			||||||
 | 
								[Column(MapType = typeof(JObject))]
 | 
				
			||||||
 | 
								public string string_to_jobject { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								[Column(MapType = typeof(string))]
 | 
				
			||||||
 | 
								public JToken jtoken_to_string { get; set; }
 | 
				
			||||||
 | 
								[Column(MapType = typeof(string))]
 | 
				
			||||||
 | 
								public JArray jarray_to_string { get; set; }
 | 
				
			||||||
 | 
								[Column(MapType = typeof(string))]
 | 
				
			||||||
 | 
								public JObject jobject_to_string { get; set; }
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void JTokenWithObjectToString() {
 | 
				
			||||||
 | 
								//insert
 | 
				
			||||||
 | 
								var orm = g.pgsql;
 | 
				
			||||||
 | 
								var item = new JTokenTestMap { };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								var find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.jtoken_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								var json = JToken.FromObject(new { test1 = 1, test2 = "222" });
 | 
				
			||||||
 | 
								item = new JTokenTestMap { jtoken_to_string = json };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json, find.jtoken_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update
 | 
				
			||||||
 | 
								json = JToken.FromObject(new { test2 = 33, test3 = "333" });
 | 
				
			||||||
 | 
								item.jtoken_to_string = json;
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json, find.jtoken_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								item.jtoken_to_string = null;
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jtoken_to_string == json).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jtoken_to_string == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.jtoken_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update set
 | 
				
			||||||
 | 
								json = JToken.FromObject(new { testa = 455, test31 = "666" });
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.jtoken_to_string, json).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json, find.jtoken_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.jtoken_to_string, null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jtoken_to_string == json).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jtoken_to_string == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.jtoken_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//delete
 | 
				
			||||||
 | 
								Assert.Equal(0, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && a.jtoken_to_string == json).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && a.jtoken_to_string == null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void JTokenWithArrayToString() {
 | 
				
			||||||
 | 
								//insert
 | 
				
			||||||
 | 
								var orm = g.pgsql;
 | 
				
			||||||
 | 
								var item = new JTokenTestMap { };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								var find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.jtoken_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								var json = JArray.FromObject(new[] { "a", "b" });
 | 
				
			||||||
 | 
								item = new JTokenTestMap { jtoken_to_string = json };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json, find.jtoken_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update
 | 
				
			||||||
 | 
								json = JArray.FromObject(new[] { "333", "zzz" });
 | 
				
			||||||
 | 
								item.jtoken_to_string = json;
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json, find.jtoken_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								item.jtoken_to_string = null;
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jtoken_to_string == json).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jtoken_to_string == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.jtoken_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update set
 | 
				
			||||||
 | 
								json = JArray.FromObject(new[] { "zxzz", "sdfsdf" });
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.jtoken_to_string, json).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json, find.jtoken_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.jtoken_to_string, null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jtoken_to_string == json).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jtoken_to_string == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.jtoken_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//delete
 | 
				
			||||||
 | 
								Assert.Equal(0, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && a.jtoken_to_string == json).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && a.jtoken_to_string == null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void JArrayToString() {
 | 
				
			||||||
 | 
								//insert
 | 
				
			||||||
 | 
								var orm = g.pgsql;
 | 
				
			||||||
 | 
								var item = new JTokenTestMap { };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								var find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.jarray_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								var json = JArray.FromObject(new[] { "a", "b" });
 | 
				
			||||||
 | 
								item = new JTokenTestMap { jarray_to_string = json };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json, find.jarray_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update
 | 
				
			||||||
 | 
								json = JArray.FromObject(new[] { "333", "zzz" });
 | 
				
			||||||
 | 
								item.jarray_to_string = json;
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json, find.jarray_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								item.jarray_to_string = null;
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jarray_to_string == json).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jarray_to_string == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.jarray_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update set
 | 
				
			||||||
 | 
								json = JArray.FromObject(new[] { "zxzz", "sdfsdf" });
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.jarray_to_string, json).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json, find.jarray_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.jarray_to_string, null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jarray_to_string == json).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jarray_to_string == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.jarray_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//delete
 | 
				
			||||||
 | 
								Assert.Equal(0, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && a.jarray_to_string == json).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && a.jarray_to_string == null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void JObjectToString() {
 | 
				
			||||||
 | 
								//insert
 | 
				
			||||||
 | 
								var orm = g.pgsql;
 | 
				
			||||||
 | 
								var item = new JTokenTestMap { };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								var find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.jobject_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								var json = JObject.FromObject(new { test1 = 1, test2 = "222" });
 | 
				
			||||||
 | 
								item = new JTokenTestMap { jobject_to_string = json };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json, find.jobject_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update
 | 
				
			||||||
 | 
								json = JObject.FromObject(new { test2 = 33, test3 = "333" });
 | 
				
			||||||
 | 
								item.jobject_to_string = json;
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json, find.jobject_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								item.jobject_to_string = null;
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jobject_to_string == json).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jobject_to_string == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.jobject_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update set
 | 
				
			||||||
 | 
								json = JObject.FromObject(new { testa = 455, test31 = "666" });
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.jobject_to_string, json).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json, find.jobject_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.jobject_to_string, null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jobject_to_string == json).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.jobject_to_string == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.jobject_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//delete
 | 
				
			||||||
 | 
								Assert.Equal(0, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && a.jobject_to_string == json).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && a.jobject_to_string == null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void StringToJToken() {
 | 
				
			||||||
 | 
								//insert
 | 
				
			||||||
 | 
								var orm = g.pgsql;
 | 
				
			||||||
 | 
								var item = new JTokenTestMap { };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								var find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.string_to_jtoken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								var json = JToken.FromObject(new { test1 = 1, test2 = "222" });
 | 
				
			||||||
 | 
								var whereJson = JToken.FromObject(new { test2 = "222" });
 | 
				
			||||||
 | 
								item = new JTokenTestMap { string_to_jtoken = json.ToString() };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JToken.Parse(a.string_to_jtoken).Contains(whereJson)).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json["test2"], JToken.Parse(find.string_to_jtoken)["test2"]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update
 | 
				
			||||||
 | 
								json = JToken.FromObject(new { test2 = 33, test3 = "333" });
 | 
				
			||||||
 | 
								whereJson = JToken.FromObject(new { test3 = "333" });
 | 
				
			||||||
 | 
								item.string_to_jtoken = json.ToString();
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JToken.Parse(a.string_to_jtoken).Contains(whereJson)).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json["test3"], JToken.Parse(find.string_to_jtoken)["test3"]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								item.string_to_jtoken = null;
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JToken.Parse(a.string_to_jtoken).Contains(whereJson)).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.string_to_jtoken == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.string_to_jtoken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update set
 | 
				
			||||||
 | 
								json = JToken.FromObject(new { testa = 455, test31 = "666" });
 | 
				
			||||||
 | 
								whereJson = JToken.FromObject(new { test31 = "666" });
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.string_to_jtoken, json.ToString()).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JToken.Parse(a.string_to_jtoken).Contains(whereJson)).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json["test31"], JToken.Parse(find.string_to_jtoken)["test31"]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.string_to_jtoken, null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JToken.Parse(a.string_to_jtoken).Contains(whereJson)).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.string_to_jtoken == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.string_to_jtoken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//delete
 | 
				
			||||||
 | 
								Assert.Equal(0, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && JToken.Parse(a.string_to_jtoken).Contains(whereJson)).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && a.string_to_jtoken == null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void StringToJObject() {
 | 
				
			||||||
 | 
								//insert
 | 
				
			||||||
 | 
								var orm = g.pgsql;
 | 
				
			||||||
 | 
								var item = new JTokenTestMap { };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								var find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.string_to_jobject);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								var json = JObject.FromObject(new { test1 = 1, test2 = "222" });
 | 
				
			||||||
 | 
								item = new JTokenTestMap { string_to_jobject = json.ToString() };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JObject.Parse(a.string_to_jobject).ContainsKey("test1")).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json["test2"], JObject.Parse(find.string_to_jobject)["test2"]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update
 | 
				
			||||||
 | 
								json = JObject.FromObject(new { test2 = 33, test3 = "333" });
 | 
				
			||||||
 | 
								item.string_to_jobject = json.ToString();
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JObject.Parse(a.string_to_jobject).ContainsKey("test3")).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json["test3"], JObject.Parse(find.string_to_jobject)["test3"]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								item.string_to_jobject = null;
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JObject.Parse(a.string_to_jobject).ContainsKey("test3")).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.string_to_jobject == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.string_to_jobject);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update set
 | 
				
			||||||
 | 
								json = JObject.FromObject(new { testa = 455, test31 = "666" });
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.string_to_jobject, json.ToString()).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JObject.Parse(a.string_to_jobject).ContainsKey("test31")).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json["test31"], JObject.Parse(find.string_to_jobject)["test31"]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.string_to_jobject, null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JObject.Parse(a.string_to_jobject).ContainsKey("test31")).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.string_to_jobject == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.string_to_jobject);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//delete
 | 
				
			||||||
 | 
								Assert.Equal(0, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && JObject.Parse(a.string_to_jobject).ContainsKey("test31")).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && a.string_to_jobject == null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void StringToJArray() {
 | 
				
			||||||
 | 
								//insert
 | 
				
			||||||
 | 
								var orm = g.pgsql;
 | 
				
			||||||
 | 
								var item = new JTokenTestMap { };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								var find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.string_to_jarray);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								var json = JArray.FromObject(new[] { "aa", "bb" });
 | 
				
			||||||
 | 
								item = new JTokenTestMap { string_to_jarray = json.ToString() };
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Insert<JTokenTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JArray.Parse(a.string_to_jarray).Contains("bb")).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json[1], JArray.Parse(find.string_to_jarray)[1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update
 | 
				
			||||||
 | 
								json = JArray.FromObject(new[] { "aa", "dddd" });
 | 
				
			||||||
 | 
								item.string_to_jarray = json.ToString();
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JArray.Parse(a.string_to_jarray).Contains("dddd")).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json[1], JArray.Parse(find.string_to_jarray)[1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								item.string_to_jarray = null;
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JArray.Parse(a.string_to_jarray).Contains("dddd")).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.string_to_jarray == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.string_to_jarray);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//update set
 | 
				
			||||||
 | 
								json = JArray.FromObject(new[] { "aa", "bdfdfb" });
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.string_to_jarray, json.ToString()).ExecuteAffrows());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JArray.Parse(a.string_to_jarray).Contains("bdfdfb")).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Equal(json[1], JArray.Parse(find.string_to_jarray)[1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Update<JTokenTestMap>().Where(a => a.id == item.id).Set(a => a.string_to_jarray, null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id && JArray.Parse(a.string_to_jarray).Contains("bdfdfb")).First());
 | 
				
			||||||
 | 
								find = orm.Select<JTokenTestMap>().Where(a => a.id == item.id && a.string_to_jarray == null).First();
 | 
				
			||||||
 | 
								Assert.NotNull(find);
 | 
				
			||||||
 | 
								Assert.Equal(item.id, find.id);
 | 
				
			||||||
 | 
								Assert.Null(find.string_to_jarray);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//delete
 | 
				
			||||||
 | 
								Assert.Equal(0, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && JArray.Parse(a.string_to_jarray).Contains("bdfdfb")).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Equal(1, orm.Delete<JTokenTestMap>().Where(a => a.id == item.id && a.string_to_jarray == null).ExecuteAffrows());
 | 
				
			||||||
 | 
								Assert.Null(orm.Select<JTokenTestMap>().Where(a => a.id == item.id).First());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										557
									
								
								FreeSql.Tests/PostgreSQL/MapType/ToStringTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										557
									
								
								FreeSql.Tests/PostgreSQL/MapType/ToStringTest.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,557 @@
 | 
				
			|||||||
 | 
					using FreeSql.DataAnnotations;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Numerics;
 | 
				
			||||||
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace FreeSql.Tests.PostgreSQLMapType {
 | 
				
			||||||
 | 
						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.pgsql;
 | 
				
			||||||
 | 
								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.pgsql;
 | 
				
			||||||
 | 
								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.pgsql;
 | 
				
			||||||
 | 
								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.pgsql;
 | 
				
			||||||
 | 
								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.pgsql;
 | 
				
			||||||
 | 
								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.pgsql;
 | 
				
			||||||
 | 
								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.pgsql;
 | 
				
			||||||
 | 
								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.pgsql;
 | 
				
			||||||
 | 
								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.pgsql;
 | 
				
			||||||
 | 
								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.pgsql;
 | 
				
			||||||
 | 
								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());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -79,10 +79,10 @@ namespace FreeSql.Tests.PostgreSQLExpression {
 | 
				
			|||||||
			var sql3 = select.Where(a => a.testFieldJObject.ContainsKey("a")).ToList();
 | 
								var sql3 = select.Where(a => a.testFieldJObject.ContainsKey("a")).ToList();
 | 
				
			||||||
			var sql4 = select.Where(a => a.testFieldJObject.ContainsKey("a") == false).ToList();
 | 
								var sql4 = select.Where(a => a.testFieldJObject.ContainsKey("a") == false).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			var sql5 = select.Where(a => a.testFieldJArray.Contains(JToken.Parse("{a:1}"))).ToList();
 | 
								var sql5 = select.Where(a => a.testFieldJArray.Contains(1)).ToList();
 | 
				
			||||||
			var sql6 = select.Where(a => a.testFieldJArray.Contains(JToken.Parse("{a:1}")) == false).ToList();
 | 
								var sql6 = select.Where(a => a.testFieldJArray.Contains(1) == false).ToList();
 | 
				
			||||||
			var sql555 = select.Where(a => a.testFieldJArray.Contains("{a:1}")).ToList();
 | 
								var sql555 = select.Where(a => a.testFieldJArray.Contains(1)).ToList();
 | 
				
			||||||
			var sql666 = select.Where(a => a.testFieldJArray.Contains("{a:1}") == false).ToList();
 | 
								var sql666 = select.Where(a => a.testFieldJArray.Contains(1) == false).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//var sql7 = select.Where(a => a.testFieldJToken.Any()).ToList();
 | 
								//var sql7 = select.Where(a => a.testFieldJToken.Any()).ToList();
 | 
				
			||||||
			//var sql8 = select.Where(a => a.testFieldJToken.Any() == false).ToList();
 | 
								//var sql8 = select.Where(a => a.testFieldJToken.Any() == false).ToList();
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1571
									
								
								FreeSql.Tests/SqlServer/MapType/BoolNullableTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1571
									
								
								FreeSql.Tests/SqlServer/MapType/BoolNullableTest.cs
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1104
									
								
								FreeSql.Tests/SqlServer/MapType/BoolTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1104
									
								
								FreeSql.Tests/SqlServer/MapType/BoolTest.cs
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										263
									
								
								FreeSql.Tests/SqlServer/MapType/EnumTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										263
									
								
								FreeSql.Tests/SqlServer/MapType/EnumTest.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,263 @@
 | 
				
			|||||||
 | 
					using FreeSql.DataAnnotations;
 | 
				
			||||||
 | 
					using FreeSql.Tests.DataContext.SqlServer;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Numerics;
 | 
				
			||||||
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace FreeSql.Tests.SqlServerMapType {
 | 
				
			||||||
 | 
						[Collection("SqlServerCollection")]
 | 
				
			||||||
 | 
						public class EnumTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							SqlServerFixture _sqlserverFixture;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							public EnumTest(SqlServerFixture sqlserverFixture) {
 | 
				
			||||||
 | 
								_sqlserverFixture = sqlserverFixture;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										565
									
								
								FreeSql.Tests/SqlServer/MapType/ToStringTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										565
									
								
								FreeSql.Tests/SqlServer/MapType/ToStringTest.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,565 @@
 | 
				
			|||||||
 | 
					using FreeSql.DataAnnotations;
 | 
				
			||||||
 | 
					using FreeSql.Tests.DataContext.SqlServer;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Numerics;
 | 
				
			||||||
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace FreeSql.Tests.SqlServerMapType {
 | 
				
			||||||
 | 
						[Collection("SqlServerCollection")]
 | 
				
			||||||
 | 
						public class ToStringTest {
 | 
				
			||||||
 | 
							SqlServerFixture _sqlserverFixture;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							public ToStringTest(SqlServerFixture sqlserverFixture) {
 | 
				
			||||||
 | 
								_sqlserverFixture = sqlserverFixture;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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 = _sqlserverFixture.SqlServer;
 | 
				
			||||||
 | 
								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());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										1562
									
								
								FreeSql.Tests/Sqlite/MapType/BoolNullableTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1562
									
								
								FreeSql.Tests/Sqlite/MapType/BoolNullableTest.cs
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1096
									
								
								FreeSql.Tests/Sqlite/MapType/BoolTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1096
									
								
								FreeSql.Tests/Sqlite/MapType/BoolTest.cs
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										254
									
								
								FreeSql.Tests/Sqlite/MapType/EnumTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										254
									
								
								FreeSql.Tests/Sqlite/MapType/EnumTest.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,254 @@
 | 
				
			|||||||
 | 
					using FreeSql.DataAnnotations;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Numerics;
 | 
				
			||||||
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace FreeSql.Tests.SqliteMapType {
 | 
				
			||||||
 | 
						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.sqlite;
 | 
				
			||||||
 | 
								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.sqlite;
 | 
				
			||||||
 | 
								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.sqlite;
 | 
				
			||||||
 | 
								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.sqlite;
 | 
				
			||||||
 | 
								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());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										557
									
								
								FreeSql.Tests/Sqlite/MapType/ToStringTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										557
									
								
								FreeSql.Tests/Sqlite/MapType/ToStringTest.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,557 @@
 | 
				
			|||||||
 | 
					using FreeSql.DataAnnotations;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Numerics;
 | 
				
			||||||
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace FreeSql.Tests.SqliteMapType {
 | 
				
			||||||
 | 
						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.sqlite;
 | 
				
			||||||
 | 
								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.sqlite;
 | 
				
			||||||
 | 
								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.sqlite;
 | 
				
			||||||
 | 
								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.sqlite;
 | 
				
			||||||
 | 
								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.sqlite;
 | 
				
			||||||
 | 
								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.sqlite;
 | 
				
			||||||
 | 
								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.sqlite;
 | 
				
			||||||
 | 
								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.sqlite;
 | 
				
			||||||
 | 
								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.sqlite;
 | 
				
			||||||
 | 
								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.sqlite;
 | 
				
			||||||
 | 
								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());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	<PropertyGroup>
 | 
						<PropertyGroup>
 | 
				
			||||||
		<TargetFramework>netstandard2.0</TargetFramework>
 | 
							<TargetFramework>netstandard2.0</TargetFramework>
 | 
				
			||||||
		<Version>0.5.4.1</Version>
 | 
							<Version>0.5.5</Version>
 | 
				
			||||||
		<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
 | 
							<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
 | 
				
			||||||
		<Authors>YeXiangQin</Authors>
 | 
							<Authors>YeXiangQin</Authors>
 | 
				
			||||||
		<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
 | 
							<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -299,12 +299,15 @@ namespace FreeSql.Internal.CommonProvider {
 | 
				
			|||||||
			_commonExpression.ExpressionSelectColumn_MemberAccess(null, cols, SelectTableInfoType.From, column?.Body, true, null);
 | 
								_commonExpression.ExpressionSelectColumn_MemberAccess(null, cols, SelectTableInfoType.From, column?.Body, true, null);
 | 
				
			||||||
			if (cols.Count != 1) return this;
 | 
								if (cols.Count != 1) return this;
 | 
				
			||||||
			var col = cols.First();
 | 
								var col = cols.First();
 | 
				
			||||||
 | 
								object paramVal = null;
 | 
				
			||||||
 | 
								if (col.Column.Attribute.MapType == typeof(TMember)) paramVal = value;
 | 
				
			||||||
 | 
								else paramVal = Utils.GetDataReaderValue(col.Column.Attribute.MapType, value);
 | 
				
			||||||
			_set.Append(", ").Append(_commonUtils.QuoteSqlName(col.Column.Attribute.Name)).Append(" = ");
 | 
								_set.Append(", ").Append(_commonUtils.QuoteSqlName(col.Column.Attribute.Name)).Append(" = ");
 | 
				
			||||||
			if (_noneParameter) {
 | 
								if (_noneParameter) {
 | 
				
			||||||
				_set.Append(_commonUtils.GetNoneParamaterSqlValue(_params, col.Column.Attribute.MapType, value));
 | 
									_set.Append(_commonUtils.GetNoneParamaterSqlValue(_params, col.Column.Attribute.MapType, paramVal));
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				_set.Append(_commonUtils.QuoteWriteParamter(col.Column.Attribute.MapType, $"{_commonUtils.QuoteParamterName("p_")}{_params.Count}"));
 | 
									_set.Append(_commonUtils.QuoteWriteParamter(col.Column.Attribute.MapType, $"{_commonUtils.QuoteParamterName("p_")}{_params.Count}"));
 | 
				
			||||||
				_commonUtils.AppendParamter(_params, null, col.Column.Attribute.MapType, value);
 | 
									_commonUtils.AppendParamter(_params, null, col.Column.Attribute.MapType, paramVal);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			//foreach (var t in _source) Utils.FillPropertyValue(t, tryf.CsName, value);
 | 
								//foreach (var t in _source) Utils.FillPropertyValue(t, tryf.CsName, value);
 | 
				
			||||||
			return this;
 | 
								return this;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -105,7 +105,10 @@ namespace FreeSql.PostgreSQL {
 | 
				
			|||||||
									case "Any": return $"(jsonb_array_length(coalesce({left},'[]')) > 0)";
 | 
														case "Any": return $"(jsonb_array_length(coalesce({left},'[]')) > 0)";
 | 
				
			||||||
									case "Contains":
 | 
														case "Contains":
 | 
				
			||||||
										var json = getExp(callExp.Arguments[argIndex]);
 | 
															var json = getExp(callExp.Arguments[argIndex]);
 | 
				
			||||||
										if (json.StartsWith("'") && json.EndsWith("'")) return $"(coalesce({left},'{{}}') @> {_common.FormatSql("{0}", JToken.Parse(json.Trim('\'')))})";
 | 
															if (objType == typeof(JArray))
 | 
				
			||||||
 | 
																return $"(coalesce({left},'[]') ? ({json})::varchar)";
 | 
				
			||||||
 | 
															if (json.StartsWith("'") && json.EndsWith("'"))
 | 
				
			||||||
 | 
																return $"(coalesce({left},'{{}}') @> {_common.FormatSql("{0}", JToken.Parse(json.Trim('\'')))})";
 | 
				
			||||||
										return $"(coalesce({left},'{{}}') @> ({json})::jsonb)";
 | 
															return $"(coalesce({left},'{{}}') @> ({json})::jsonb)";
 | 
				
			||||||
									case "ContainsKey": return $"(coalesce({left},'{{}}') ? {getExp(callExp.Arguments[argIndex])})";
 | 
														case "ContainsKey": return $"(coalesce({left},'{{}}') ? {getExp(callExp.Arguments[argIndex])})";
 | 
				
			||||||
									case "Concat":
 | 
														case "Concat":
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -213,7 +213,7 @@ namespace FreeSql.Sqlite {
 | 
				
			|||||||
				if (isIndent == false && tb.Primarys.Any()) {
 | 
									if (isIndent == false && tb.Primarys.Any()) {
 | 
				
			||||||
					sb.Append(" \r\n  PRIMARY KEY (");
 | 
										sb.Append(" \r\n  PRIMARY KEY (");
 | 
				
			||||||
					foreach (var tbcol in tb.Primarys) sb.Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(", ");
 | 
										foreach (var tbcol in tb.Primarys) sb.Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(", ");
 | 
				
			||||||
					sb.Remove(sb.Length - 2, 2).Append(")");
 | 
										sb.Remove(sb.Length - 2, 2).Append("),");
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				foreach (var uk in tb.Uniques) {
 | 
									foreach (var uk in tb.Uniques) {
 | 
				
			||||||
					sb.Append(" \r\n  CONSTRAINT ").Append(_commonUtils.QuoteSqlName(uk.Key)).Append(" UNIQUE(");
 | 
										sb.Append(" \r\n  CONSTRAINT ").Append(_commonUtils.QuoteSqlName(uk.Key)).Append(" UNIQUE(");
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user