Synchronization code

This commit is contained in:
sunkaixuan 2023-05-28 12:56:59 +08:00
parent 1759bd4c3e
commit ca7ea939cb
2 changed files with 18 additions and 2 deletions

View File

@ -42,7 +42,7 @@ namespace SqlSugar
}
else
{
var type = value.GetType();
var type = UtilMethods.GetUnderType(value.GetType());
if (type == UtilConstants.DateType)
{
var date = value.ObjToDate();
@ -52,6 +52,10 @@ namespace SqlSugar
}
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
}
else if (type == UtilConstants.DateTimeOffsetType)
{
return FormatDateTimeOffset(value);
}
else if (type == UtilConstants.ByteArrayType)
{
string bytesString = "0x" + BitConverter.ToString((byte[])value);
@ -217,5 +221,9 @@ namespace SqlSugar
columnsString = columnsString.Replace(Builder.GetTranslationColumnName(this.ShortName) + ".", "") + joinString;
return string.Format(SqlTemplate, tableName, columnsString, whereString);
}
public override string FormatDateTimeOffset(object value)
{
return "'" + ((DateTimeOffset)value).ToString("o") + "'";
}
}
}

View File

@ -42,7 +42,7 @@ namespace SqlSugar
}
else
{
var type = value.GetType();
var type =UtilMethods.GetUnderType(value.GetType());
if (type == UtilConstants.DateType||columnInfo.IsArray||columnInfo.IsJson)
{
var parameterName = this.Builder.SqlParameterKeyWord + name + i;
@ -58,6 +58,10 @@ namespace SqlSugar
this.Parameters.Add(paramter);
return parameterName;
}
else if (type == UtilConstants.DateTimeOffsetType)
{
return FormatDateTimeOffset(value);
}
else if (type == UtilConstants.ByteArrayType)
{
string bytesString = "0x" + BitConverter.ToString((byte[])value);
@ -237,5 +241,9 @@ namespace SqlSugar
columnsString = columnsString.Replace(Builder.GetTranslationColumnName(this.ShortName)+".","")+joinString;
return string.Format(SqlTemplate, tableName, columnsString, whereString);
}
public override string FormatDateTimeOffset(object value)
{
return "'" + ((DateTimeOffset)value).ToString("o") + "'";
}
}
}