mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Code optimization
This commit is contained in:
parent
330638f5e1
commit
ce1431b803
@ -174,11 +174,7 @@ namespace SqlSugar
|
|||||||
bool isNullableType = false;
|
bool isNullableType = false;
|
||||||
MethodInfo method = null;
|
MethodInfo method = null;
|
||||||
Type bindPropertyType = UtilMethods.GetUnderType(bindProperty, ref isNullableType);
|
Type bindPropertyType = UtilMethods.GetUnderType(bindProperty, ref isNullableType);
|
||||||
string dbTypeName = DataRecord.GetDataTypeName(ordinal);
|
string dbTypeName = UtilMethods.GetParenthesesValue(DataRecord.GetDataTypeName(ordinal));
|
||||||
if (Regex.IsMatch(dbTypeName, @"\(.+\)"))
|
|
||||||
{
|
|
||||||
dbTypeName = Regex.Replace(dbTypeName, @"\(.+\)", "");
|
|
||||||
}
|
|
||||||
string propertyName = bindProperty.Name;
|
string propertyName = bindProperty.Name;
|
||||||
string validPropertyName = bind.GetPropertyTypeName(dbTypeName);
|
string validPropertyName = bind.GetPropertyTypeName(dbTypeName);
|
||||||
validPropertyName = validPropertyName == "byte[]" ? "byteArray" : validPropertyName;
|
validPropertyName = validPropertyName == "byte[]" ? "byteArray" : validPropertyName;
|
||||||
@ -241,7 +237,7 @@ namespace SqlSugar
|
|||||||
method = getString;
|
method = getString;
|
||||||
if (bindProperyTypeName == "guid")
|
if (bindProperyTypeName == "guid")
|
||||||
{
|
{
|
||||||
method =isNullableType? getConvertStringGuid : getStringGuid;
|
method = isNullableType ? getConvertStringGuid : getStringGuid;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CSharpDataType.DateTime:
|
case CSharpDataType.DateTime:
|
||||||
@ -259,7 +255,7 @@ namespace SqlSugar
|
|||||||
CheckType(bind.DoubleThrow, bindProperyTypeName, validPropertyName, propertyName);
|
CheckType(bind.DoubleThrow, bindProperyTypeName, validPropertyName, propertyName);
|
||||||
if (bindProperyTypeName == "double")
|
if (bindProperyTypeName == "double")
|
||||||
method = isNullableType ? getConvertDouble : getDouble;
|
method = isNullableType ? getConvertDouble : getDouble;
|
||||||
if(bindProperyTypeName=="single")
|
if (bindProperyTypeName == "single")
|
||||||
method = isNullableType ? getConvertFloat : getFloat;
|
method = isNullableType ? getConvertFloat : getFloat;
|
||||||
break;
|
break;
|
||||||
case CSharpDataType.Guid:
|
case CSharpDataType.Guid:
|
||||||
@ -284,7 +280,7 @@ namespace SqlSugar
|
|||||||
method = isNullableType ? getConvertInt64 : getInt64;
|
method = isNullableType ? getConvertInt64 : getInt64;
|
||||||
break;
|
break;
|
||||||
case CSharpDataType.DateTimeOffset:
|
case CSharpDataType.DateTimeOffset:
|
||||||
method = isNullableType ? getConvertdatetimeoffset : getdatetimeoffset;
|
method = isNullableType ? getConvertdatetimeoffset : getdatetimeoffset;
|
||||||
if (bindProperyTypeName == "datetime")
|
if (bindProperyTypeName == "datetime")
|
||||||
method = isNullableType ? getConvertdatetimeoffsetDate : getdatetimeoffsetDate;
|
method = isNullableType ? getConvertdatetimeoffsetDate : getdatetimeoffsetDate;
|
||||||
break;
|
break;
|
||||||
@ -296,7 +292,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
method = getConvertString;
|
method = getConvertString;
|
||||||
}
|
}
|
||||||
if (bindPropertyType == UtilConstants.ObjType) {
|
if (bindPropertyType == UtilConstants.ObjType)
|
||||||
|
{
|
||||||
method = getValueMethod;
|
method = getValueMethod;
|
||||||
}
|
}
|
||||||
if (method == null)
|
if (method == null)
|
||||||
|
@ -5,6 +5,8 @@ using System.Data.SqlClient;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public class UtilMethods
|
public class UtilMethods
|
||||||
@ -74,5 +76,16 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return string.Format(" ({0}) {1} ", sql, shortName);
|
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 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