Update core

This commit is contained in:
skx
2020-12-30 18:44:34 +08:00
parent 02e7e72bb5
commit 2ef8e14522
3 changed files with 32 additions and 7 deletions

View File

@@ -280,6 +280,8 @@ namespace SqlSugar
method = isNullableType ? getConvertDateTime : getDateTime; method = isNullableType ? getConvertDateTime : getDateTime;
if (bindProperyTypeName == "datetime" && dbTypeName.ToLower() == "time") if (bindProperyTypeName == "datetime" && dbTypeName.ToLower() == "time")
method = isNullableType ? getConvertTime : getTime; method = isNullableType ? getConvertTime : getTime;
if (bindProperyTypeName == "datetimeoffset")
method = isNullableType ? getConvertdatetimeoffset : getdatetimeoffset;
break; break;
case CSharpDataType.@decimal: case CSharpDataType.@decimal:
CheckType(bind.DecimalThrow, bindProperyTypeName, validPropertyName, propertyName); CheckType(bind.DecimalThrow, bindProperyTypeName, validPropertyName, propertyName);

View File

@@ -217,8 +217,16 @@ namespace SqlSugar
{ {
return default(DateTimeOffset); return default(DateTimeOffset);
} }
var result = (DateTimeOffset)dr.GetValue(i); var date = dr.GetValue(i);
return result; if (date is DateTime)
{
return UtilMethods.GetDateTimeOffsetByDateTime((DateTime)(date));
}
else
{
var result = (DateTimeOffset)date;
return result;
}
} }
public static DateTimeOffset? GetConvertdatetimeoffset(this IDataRecord dr, int i) public static DateTimeOffset? GetConvertdatetimeoffset(this IDataRecord dr, int i)
@@ -227,8 +235,16 @@ namespace SqlSugar
{ {
return default(DateTimeOffset); return default(DateTimeOffset);
} }
var result = (DateTimeOffset)dr.GetValue(i); var date = dr.GetValue(i);
return result; if (date is DateTime)
{
return UtilMethods.GetDateTimeOffsetByDateTime((DateTime)(date));
}
else
{
var result = (DateTimeOffset)date;
return result;
}
} }

View File

@@ -55,7 +55,7 @@ namespace SqlSugar
for (int i = 0; i < st.FrameCount; i++) for (int i = 0; i < st.FrameCount; i++)
{ {
var frame = st.GetFrame(i); var frame = st.GetFrame(i);
if (frame.GetMethod().Module.Name.ToLower() != "sqlsugar.dll"&& frame.GetMethod().Name.First()!='<') if (frame.GetMethod().Module.Name.ToLower() != "sqlsugar.dll" && frame.GetMethod().Name.First() != '<')
{ {
info.MyStackTraceList.Add(new StackTraceInfoItem() info.MyStackTraceList.Add(new StackTraceInfoItem()
{ {
@@ -93,8 +93,8 @@ namespace SqlSugar
itemSql = Regex.Replace(itemSql, string.Format(@"{0}\,", "\\" + itemParameter.ParameterName), newName + ",", RegexOptions.IgnoreCase); itemSql = Regex.Replace(itemSql, string.Format(@"{0}\,", "\\" + itemParameter.ParameterName), newName + ",", RegexOptions.IgnoreCase);
itemSql = Regex.Replace(itemSql, string.Format(@"{0}$", "\\" + itemParameter.ParameterName), newName, RegexOptions.IgnoreCase); itemSql = Regex.Replace(itemSql, string.Format(@"{0}$", "\\" + itemParameter.ParameterName), newName, RegexOptions.IgnoreCase);
itemSql = Regex.Replace(itemSql, string.Format(@"\+{0}\+", "\\" + itemParameter.ParameterName), "+" + newName + "+", RegexOptions.IgnoreCase); itemSql = Regex.Replace(itemSql, string.Format(@"\+{0}\+", "\\" + itemParameter.ParameterName), "+" + newName + "+", RegexOptions.IgnoreCase);
itemSql = Regex.Replace(itemSql, string.Format(@"\+{0} ", "\\" + itemParameter.ParameterName), "+" + newName +" ", RegexOptions.IgnoreCase); itemSql = Regex.Replace(itemSql, string.Format(@"\+{0} ", "\\" + itemParameter.ParameterName), "+" + newName + " ", RegexOptions.IgnoreCase);
itemSql = Regex.Replace(itemSql, string.Format(@" {0}\+", "\\" + itemParameter.ParameterName)," "+ newName + "+", RegexOptions.IgnoreCase); itemSql = Regex.Replace(itemSql, string.Format(@" {0}\+", "\\" + itemParameter.ParameterName), " " + newName + "+", RegexOptions.IgnoreCase);
itemSql = Regex.Replace(itemSql, string.Format(@"\|\|{0}\|\|", "\\" + itemParameter.ParameterName), "+" + newName + "+", RegexOptions.IgnoreCase); itemSql = Regex.Replace(itemSql, string.Format(@"\|\|{0}\|\|", "\\" + itemParameter.ParameterName), "+" + newName + "+", RegexOptions.IgnoreCase);
return itemSql; return itemSql;
} }
@@ -154,6 +154,13 @@ namespace SqlSugar
return (T)Convert.ChangeType(obj, typeof(T)); return (T)Convert.ChangeType(obj, typeof(T));
} }
internal static DateTimeOffset GetDateTimeOffsetByDateTime(DateTime date)
{
date = DateTime.SpecifyKind(date, DateTimeKind.Utc);
DateTimeOffset utcTime2 = date;
return utcTime2;
}
internal static void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex, string append = null) internal static void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex, string append = null)
{ {
if (appendSql.HasValue() && parameters.HasValue()) if (appendSql.HasValue() && parameters.HasValue())