mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Code optimization
This commit is contained in:
parent
330638f5e1
commit
ce1431b803
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user