修复DB2插入时日期转换问题

This commit is contained in:
Kenton 2025-03-14 17:34:50 +08:00
parent 12249dee26
commit db3dd58302
3 changed files with 8 additions and 4 deletions

View File

@ -90,9 +90,9 @@ namespace SqlSugar.DB2
new KeyValuePair<string, CSharpDataType>("char",CSharpDataType.@string),
new KeyValuePair<string, CSharpDataType>("clob",CSharpDataType.@string),
new KeyValuePair<string, CSharpDataType>("timestamp",CSharpDataType.@DateTime),
new KeyValuePair<string, CSharpDataType>("date",CSharpDataType.@DateTime),
new KeyValuePair<string, CSharpDataType>("time",CSharpDataType.@DateTime),
new KeyValuePair<string, CSharpDataType>("timestamp",CSharpDataType.@DateTime),
new KeyValuePair<string, CSharpDataType>("integer",CSharpDataType.@int),
new KeyValuePair<string, CSharpDataType>("smallint",CSharpDataType.@short),

View File

@ -238,7 +238,7 @@ namespace SqlSugar.DB2
{
var parameter = model.Args[0];
var parameter2 = model.Args[1];
return string.Format(" ({0} like concat('%',{1},'%')) ", parameter.MemberName, parameter2.MemberName );
return string.Format(" ({0} like concat('%',concat({1},'%'))) ", parameter.MemberName, parameter2.MemberName );
}
public override string StartsWith(MethodCallExpressionModel model)

View File

@ -90,7 +90,11 @@ namespace SqlSugar.DB2
object value = null;
if (it.Value is DateTime)
{
value = ((DateTime)it.Value).ToString("O");
value = ((DateTime)it.Value).ToString("yyyy-MM-dd HH:mm:ss.fff");
}
else if (it.Value is Boolean)
{
value = ((Boolean)it.Value) ? 1 : 0;
}
else if (it.Value is DateTimeOffset)
{
@ -179,7 +183,7 @@ namespace SqlSugar.DB2
}
public override string FormatDateTimeOffset(object value)
{
return "'" + ((DateTimeOffset)value).ToString("o") + "'";
return "'" + ((DateTimeOffset)value).ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
}
}