diff --git a/Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs b/Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs index eae7e1e4c..1cf4e2fb8 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs @@ -174,11 +174,7 @@ namespace SqlSugar bool isNullableType = false; MethodInfo method = null; Type bindPropertyType = UtilMethods.GetUnderType(bindProperty, ref isNullableType); - string dbTypeName = DataRecord.GetDataTypeName(ordinal); - if (Regex.IsMatch(dbTypeName, @"\(.+\)")) - { - dbTypeName = Regex.Replace(dbTypeName, @"\(.+\)", ""); - } + string dbTypeName = UtilMethods.GetParenthesesValue(DataRecord.GetDataTypeName(ordinal)); string propertyName = bindProperty.Name; string validPropertyName = bind.GetPropertyTypeName(dbTypeName); validPropertyName = validPropertyName == "byte[]" ? "byteArray" : validPropertyName; @@ -241,7 +237,7 @@ namespace SqlSugar method = getString; if (bindProperyTypeName == "guid") { - method =isNullableType? getConvertStringGuid : getStringGuid; + method = isNullableType ? getConvertStringGuid : getStringGuid; } break; case CSharpDataType.DateTime: @@ -259,7 +255,7 @@ namespace SqlSugar CheckType(bind.DoubleThrow, bindProperyTypeName, validPropertyName, propertyName); if (bindProperyTypeName == "double") method = isNullableType ? getConvertDouble : getDouble; - if(bindProperyTypeName=="single") + if (bindProperyTypeName == "single") method = isNullableType ? getConvertFloat : getFloat; break; case CSharpDataType.Guid: @@ -284,7 +280,7 @@ namespace SqlSugar method = isNullableType ? getConvertInt64 : getInt64; break; case CSharpDataType.DateTimeOffset: - method = isNullableType ? getConvertdatetimeoffset : getdatetimeoffset; + method = isNullableType ? getConvertdatetimeoffset : getdatetimeoffset; if (bindProperyTypeName == "datetime") method = isNullableType ? getConvertdatetimeoffsetDate : getdatetimeoffsetDate; break; @@ -296,7 +292,8 @@ namespace SqlSugar { method = getConvertString; } - if (bindPropertyType == UtilConstants.ObjType) { + if (bindPropertyType == UtilConstants.ObjType) + { method = getValueMethod; } if (method == null) diff --git a/Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs b/Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs index 685fd5541..70a2a96e9 100644 --- a/Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs +++ b/Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs @@ -5,6 +5,8 @@ using System.Data.SqlClient; using System.Linq; using System.Reflection; using System.Text; +using System.Text.RegularExpressions; + namespace SqlSugar { public class UtilMethods @@ -74,5 +76,16 @@ namespace SqlSugar { return string.Format(" ({0}) {1} ", sql, shortName); } + + internal static string GetParenthesesValue(string dbTypeName) + { + if (Regex.IsMatch(dbTypeName, @"\(.+\)")) + { + dbTypeName = Regex.Replace(dbTypeName, @"\(.+\)", ""); + } + dbTypeName = dbTypeName.Trim(); + return dbTypeName; + } + } } diff --git a/Src/Asp.Net/SqliteTest/Config.cs b/Src/Asp.Net/SqliteTest/Config.cs index 37a7134bd..a506f50ff 100644 --- a/Src/Asp.Net/SqliteTest/Config.cs +++ b/Src/Asp.Net/SqliteTest/Config.cs @@ -8,6 +8,6 @@ namespace OrmTest { public class Config { - public static string ConnectionString = @"DataSource=F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\Src\Asp.Net\SqliteTest\DataBase\SqlSugar4xTest.sqlite"; + public static string ConnectionString = @"DataSource=D:\MyGit\SqlSugar\Src\Asp.Net\SqliteTest\DataBase\SqlSugar4xTest.sqlite"; } } diff --git a/Src/Asp.Net/SqliteTest/DataBase/SqlSugar4xTest.sqlite b/Src/Asp.Net/SqliteTest/DataBase/SqlSugar4xTest.sqlite index 45561c088..f96f67cbe 100644 Binary files a/Src/Asp.Net/SqliteTest/DataBase/SqlSugar4xTest.sqlite and b/Src/Asp.Net/SqliteTest/DataBase/SqlSugar4xTest.sqlite differ