mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	- 修复 Enum 类型无元素时的错误;
This commit is contained in:
		@@ -371,6 +371,11 @@ namespace FreeSql.Tests.Sqlite
 | 
				
			|||||||
            public TableAllTypeEnumType1? Enum1Nullable { get; set; }
 | 
					            public TableAllTypeEnumType1? Enum1Nullable { get; set; }
 | 
				
			||||||
            public TableAllTypeEnumType2 Enum2 { get; set; }
 | 
					            public TableAllTypeEnumType2 Enum2 { get; set; }
 | 
				
			||||||
            public TableAllTypeEnumType2? Enum2Nullable { get; set; }
 | 
					            public TableAllTypeEnumType2? Enum2Nullable { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            public TableAllTypeEnumType3 testFieldEnum3 { get; set; }
 | 
				
			||||||
 | 
					            public TableAllTypeEnumType3? testFieldEnum3Nullable { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            public enum TableAllTypeEnumType3 { }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public enum TableAllTypeEnumType1 { e1, e2, e3, e5 }
 | 
					        public enum TableAllTypeEnumType1 { e1, e2, e3, e5 }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -109,7 +109,7 @@ public class g
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    static Lazy<IFreeSql> damengLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
 | 
					    static Lazy<IFreeSql> damengLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
 | 
				
			||||||
        .UseConnectionString(FreeSql.DataType.Dameng, "server=127.0.0.1;port=5236;user id=2user;password=123456789;database=2user;poolsize=5")
 | 
					        .UseConnectionString(FreeSql.DataType.Dameng, "server=127.0.0.1;port=5236;user id=2user;password=123456789;database=2user;poolsize=5")
 | 
				
			||||||
         //.UseConnectionFactory(FreeSql.DataType.Dameng, () => new Dm.DmConnection("data source=127.0.0.1:5236;user id=2user;password=123456789;Pooling=true;Max Pool Size=2"))
 | 
					         //.UseConnectionFactory(FreeSql.DataType.Dameng, () => new Dm.DmConnection("data source=127.0.0.1:5236;user id=2user;password=123456789;Pooling=true;poolsize=2"))
 | 
				
			||||||
         .UseAutoSyncStructure(true)
 | 
					         .UseAutoSyncStructure(true)
 | 
				
			||||||
        .UseLazyLoading(true)
 | 
					        .UseLazyLoading(true)
 | 
				
			||||||
        .UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
 | 
					        .UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,8 +60,8 @@ namespace FreeSql.Dameng
 | 
				
			|||||||
            if (enumType != null)
 | 
					            if (enumType != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    CsToDb.New(DmDbType.Int32, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    CsToDb.New(DmDbType.Int32, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    CsToDb.New(DmDbType.Int64, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0));
 | 
					                    CsToDb.New(DmDbType.Int64, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
					                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    lock (_dicCsToDbLock)
 | 
					                    lock (_dicCsToDbLock)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,8 +56,8 @@ namespace FreeSql.MsAccess
 | 
				
			|||||||
            if (enumType != null)
 | 
					            if (enumType != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    CsToDb.New(OleDbType.BigInt, "decimal", $"decimal(20,0){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    CsToDb.New(OleDbType.BigInt, "decimal", $"decimal(20,0){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    CsToDb.New(OleDbType.Integer, "decimal", $"decimal(11,0){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0));
 | 
					                    CsToDb.New(OleDbType.Integer, "decimal", $"decimal(11,0){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
					                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    lock (_dicCsToDbLock)
 | 
					                    lock (_dicCsToDbLock)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -64,8 +64,8 @@ namespace FreeSql.MySql
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                var names = string.Join(",", Enum.GetNames(enumType).Select(a => _commonUtils.FormatSql("{0}", a)));
 | 
					                var names = string.Join(",", Enum.GetNames(enumType).Select(a => _commonUtils.FormatSql("{0}", a)));
 | 
				
			||||||
                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    CsToDb.New(MySqlDbType.Set, "set", $"set({names}){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    CsToDb.New(MySqlDbType.Set, "set", $"set({names}){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    CsToDb.New(MySqlDbType.Enum, "enum", $"enum({names}){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0));
 | 
					                    CsToDb.New(MySqlDbType.Enum, "enum", $"enum({names}){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
					                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    lock (_dicCsToDbLock)
 | 
					                    lock (_dicCsToDbLock)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,8 +60,8 @@ namespace FreeSql.Odbc.Dameng
 | 
				
			|||||||
            if (enumType != null)
 | 
					            if (enumType != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    CsToDb.New(OdbcType.Int, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    CsToDb.New(OdbcType.Int, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    CsToDb.New(OdbcType.BigInt, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0));
 | 
					                    CsToDb.New(OdbcType.BigInt, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
					                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    lock (_dicCsToDbLock)
 | 
					                    lock (_dicCsToDbLock)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -74,8 +74,8 @@ namespace FreeSql.Odbc.Default
 | 
				
			|||||||
            if (enumType != null)
 | 
					            if (enumType != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    CsToDb.New(OdbcType.BigInt, _utils.Adapter.MappingOdbcTypeBigInt, $"{_utils.Adapter.MappingOdbcTypeBigInt}{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    CsToDb.New(OdbcType.BigInt, _utils.Adapter.MappingOdbcTypeBigInt, $"{_utils.Adapter.MappingOdbcTypeBigInt}{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    CsToDb.New(OdbcType.Int, _utils.Adapter.MappingOdbcTypeInt, $"{_utils.Adapter.MappingOdbcTypeInt}{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0));
 | 
					                    CsToDb.New(OdbcType.Int, _utils.Adapter.MappingOdbcTypeInt, $"{_utils.Adapter.MappingOdbcTypeInt}{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
					                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    lock (_dicCsToDbLock)
 | 
					                    lock (_dicCsToDbLock)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,8 +57,8 @@ namespace FreeSql.Odbc.MySql
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                var names = string.Join(",", Enum.GetNames(enumType).Select(a => _commonUtils.FormatSql("{0}", a)));
 | 
					                var names = string.Join(",", Enum.GetNames(enumType).Select(a => _commonUtils.FormatSql("{0}", a)));
 | 
				
			||||||
                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    CsToDb.New(OdbcType.VarChar, "set", $"set({names}){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    CsToDb.New(OdbcType.VarChar, "set", $"set({names}){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    CsToDb.New(OdbcType.VarChar, "enum", $"enum({names}){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0));
 | 
					                    CsToDb.New(OdbcType.VarChar, "enum", $"enum({names}){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
					                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    lock (_dicCsToDbLock)
 | 
					                    lock (_dicCsToDbLock)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,8 +60,8 @@ namespace FreeSql.Odbc.Oracle
 | 
				
			|||||||
            if (enumType != null)
 | 
					            if (enumType != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    CsToDb.New(OdbcType.Int, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    CsToDb.New(OdbcType.Int, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    CsToDb.New(OdbcType.BigInt, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0));
 | 
					                    CsToDb.New(OdbcType.BigInt, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
					                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    lock (_dicCsToDbLock)
 | 
					                    lock (_dicCsToDbLock)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -64,8 +64,8 @@ namespace FreeSql.Odbc.PostgreSQL
 | 
				
			|||||||
            if (enumType != null)
 | 
					            if (enumType != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    CsToDb.New(OdbcType.Int, "int8", $"int8{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    CsToDb.New(OdbcType.Int, "int8", $"int8{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    CsToDb.New(OdbcType.BigInt, "int4", $"int4{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0));
 | 
					                    CsToDb.New(OdbcType.BigInt, "int4", $"int4{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
					                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    lock (_dicCsToDbLock)
 | 
					                    lock (_dicCsToDbLock)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,8 +50,8 @@ namespace FreeSql.Odbc.PostgreSQL
 | 
				
			|||||||
                    if (genericTypesFirst.IsEnum) enumType = genericTypesFirst;
 | 
					                    if (genericTypesFirst.IsEnum) enumType = genericTypesFirst;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (enumType != null) return enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                if (enumType != null) return enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    getParamterArrayValue(typeof(long), value, elementType.IsEnum ? null : Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    getParamterArrayValue(typeof(long), value, elementType.IsEnum ? null : enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    getParamterArrayValue(typeof(int), value, elementType.IsEnum ? null : Enum.GetValues(enumType).GetValue(0));
 | 
					                    getParamterArrayValue(typeof(int), value, elementType.IsEnum ? null : enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                return dicGetParamterValue.TryGetValue(type.FullName, out var trydicarr) ? trydicarr(value) : value;
 | 
					                return dicGetParamterValue.TryGetValue(type.FullName, out var trydicarr) ? trydicarr(value) : value;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (type.IsNullableType()) type = type.GetGenericArguments().First();
 | 
					            if (type.IsNullableType()) type = type.GetGenericArguments().First();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,8 +56,8 @@ namespace FreeSql.Odbc.SqlServer
 | 
				
			|||||||
            if (enumType != null)
 | 
					            if (enumType != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    CsToDb.New(OdbcType.BigInt, "bigint", $"bigint{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    CsToDb.New(OdbcType.BigInt, "bigint", $"bigint{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    CsToDb.New(OdbcType.Int, "int", $"int{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0));
 | 
					                    CsToDb.New(OdbcType.Int, "int", $"int{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
					                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    lock (_dicCsToDbLock)
 | 
					                    lock (_dicCsToDbLock)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -61,8 +61,8 @@ namespace FreeSql.Oracle
 | 
				
			|||||||
            if (enumType != null)
 | 
					            if (enumType != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    CsToDb.New(OracleDbType.Int32, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    CsToDb.New(OracleDbType.Int32, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    CsToDb.New(OracleDbType.Int64, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0));
 | 
					                    CsToDb.New(OracleDbType.Int64, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
					                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    lock (_dicCsToDbLock)
 | 
					                    lock (_dicCsToDbLock)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -99,8 +99,8 @@ namespace FreeSql.PostgreSQL
 | 
				
			|||||||
            if (enumType != null)
 | 
					            if (enumType != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    CsToDb.New(NpgsqlDbType.Bigint, "int8", $"int8{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    CsToDb.New(NpgsqlDbType.Bigint, "int8", $"int8{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    CsToDb.New(NpgsqlDbType.Integer, "int4", $"int4{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0));
 | 
					                    CsToDb.New(NpgsqlDbType.Integer, "int4", $"int4{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
					                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    lock (_dicCsToDbLock)
 | 
					                    lock (_dicCsToDbLock)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,8 +68,8 @@ namespace FreeSql.PostgreSQL
 | 
				
			|||||||
                if (elementType.IsEnum) enumType = elementType;
 | 
					                if (elementType.IsEnum) enumType = elementType;
 | 
				
			||||||
                else if (elementType.IsNullableType() && elementType.GenericTypeArguments.First().IsEnum) enumType = elementType.GenericTypeArguments.First();
 | 
					                else if (elementType.IsNullableType() && elementType.GenericTypeArguments.First().IsEnum) enumType = elementType.GenericTypeArguments.First();
 | 
				
			||||||
                if (enumType != null) return enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                if (enumType != null) return enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    getParamterArrayValue(typeof(long), value, elementType.IsEnum ? null : Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    getParamterArrayValue(typeof(long), value, elementType.IsEnum ? null : enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    getParamterArrayValue(typeof(int), value, elementType.IsEnum ? null : Enum.GetValues(enumType).GetValue(0));
 | 
					                    getParamterArrayValue(typeof(int), value, elementType.IsEnum ? null : enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                return dicGetParamterValue.TryGetValue(type.FullName, out var trydicarr) ? trydicarr(value) : value;
 | 
					                return dicGetParamterValue.TryGetValue(type.FullName, out var trydicarr) ? trydicarr(value) : value;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (type.IsNullableType()) type = type.GenericTypeArguments.First();
 | 
					            if (type.IsNullableType()) type = type.GenericTypeArguments.First();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,8 +55,8 @@ namespace FreeSql.SqlServer
 | 
				
			|||||||
            if (enumType != null)
 | 
					            if (enumType != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    CsToDb.New(SqlDbType.BigInt, "bigint", $"bigint{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    CsToDb.New(SqlDbType.BigInt, "bigint", $"bigint{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    CsToDb.New(SqlDbType.Int, "int", $"int{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0));
 | 
					                    CsToDb.New(SqlDbType.Int, "int", $"int{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
					                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    lock (_dicCsToDbLock)
 | 
					                    lock (_dicCsToDbLock)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,8 +55,8 @@ namespace FreeSql.Sqlite
 | 
				
			|||||||
            if (enumType != null)
 | 
					            if (enumType != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
					                var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
 | 
				
			||||||
                    CsToDb.New(DbType.Int64, "bigint", $"bigint{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0)) :
 | 
					                    CsToDb.New(DbType.Int64, "bigint", $"bigint{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
 | 
				
			||||||
                    CsToDb.New(DbType.Int32, "mediumint", $"mediumint{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, Enum.GetValues(enumType).GetValue(0));
 | 
					                    CsToDb.New(DbType.Int32, "mediumint", $"mediumint{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
 | 
				
			||||||
                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
					                if (_dicCsToDb.ContainsKey(type.FullName) == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    lock (_dicCsToDbLock)
 | 
					                    lock (_dicCsToDbLock)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user