mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Update pgsql & 人大金仓
This commit is contained in:
parent
8364ea6b1d
commit
6c5b1de579
@ -304,7 +304,7 @@ namespace SqlSugar
|
||||
GetDbColumnIndex++;
|
||||
return pname;
|
||||
}
|
||||
else if (columnInfo.PropertyType!=null&&columnInfo.PropertyType.Name == "TimeOnly" && name != null && !name.ObjToString().StartsWith(Builder.SqlParameterKeyWord))
|
||||
else if (columnInfo.PropertyType!=null&&columnInfo.PropertyType.Name == "TimeOnly" )
|
||||
{
|
||||
var timeSpan = UtilMethods.TimeOnlyToTimeSpan(columnInfo.Value);
|
||||
var pname = Builder.SqlParameterKeyWord + columnInfo.DbColumnName + "_ts" + GetDbColumnIndex;
|
||||
@ -312,6 +312,14 @@ namespace SqlSugar
|
||||
GetDbColumnIndex++;
|
||||
return pname;
|
||||
}
|
||||
else if (columnInfo.PropertyType != null && columnInfo.PropertyType.Name == "DateOnly")
|
||||
{
|
||||
var timeSpan = UtilMethods.DateOnlyToDateTime(columnInfo.Value);
|
||||
var pname = Builder.SqlParameterKeyWord + columnInfo.DbColumnName + "_ts" + GetDbColumnIndex;
|
||||
this.Parameters.Add(new SugarParameter(pname,Convert.ToDateTime(timeSpan)));
|
||||
GetDbColumnIndex++;
|
||||
return pname;
|
||||
}
|
||||
else
|
||||
{
|
||||
return name + "";
|
||||
|
@ -165,12 +165,12 @@ namespace SqlSugar
|
||||
else if (type?.Name == "TimeOnly")
|
||||
{
|
||||
this.DbType = System.Data.DbType.Time;
|
||||
this.Value = UtilMethods.TimeOnlyToTimeSpan(this.Value);
|
||||
this.Value =UtilMethods.TimeOnlyToTimeSpan(this.Value);
|
||||
}
|
||||
else if (type?.Name == "DateOnly")
|
||||
{
|
||||
this.DbType = System.Data.DbType.Date;
|
||||
this.Value = UtilMethods.DateOnlyToDateTime(this.Value);
|
||||
this.Value =Convert.ToDateTime(UtilMethods.DateOnlyToDateTime(this.Value));
|
||||
}
|
||||
else if (type?.FullName == "Newtonsoft.Json.Linq.JObject" || type?.FullName == "Newtonsoft.Json.Linq.JArray" || type?.FullName == "Newtonsoft.Json.Linq.JValue")
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ namespace SqlSugar
|
||||
}
|
||||
batchInsetrSql.Append("\r\n ( " + string.Join(",", columns.Select(it =>
|
||||
{
|
||||
if (it.InsertServerTime || it.InsertSql.HasValue())
|
||||
if (it.InsertServerTime || it.InsertSql.HasValue() || it.SqlParameterDbType != null || it?.PropertyType?.Name == "DateOnly" || it?.PropertyType?.Name == "TimeOnly")
|
||||
{
|
||||
return GetDbColumn(it, null);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace SqlSugar
|
||||
}
|
||||
batchInsetrSql.Append("\r\n ( " + string.Join(",", columns.Select(it =>
|
||||
{
|
||||
if (it.InsertServerTime || it.InsertSql.HasValue())
|
||||
if (it.InsertServerTime || it.InsertSql.HasValue()||it.SqlParameterDbType!=null|| it?.PropertyType?.Name=="DateOnly" || it?.PropertyType?.Name == "TimeOnly")
|
||||
{
|
||||
return GetDbColumn(it, null);
|
||||
}
|
||||
|
@ -104,7 +104,12 @@ namespace SqlSugar
|
||||
{
|
||||
destinationType = UtilMethods.GetUnderType(destinationType);
|
||||
var sourceType = value.GetType();
|
||||
|
||||
if (destinationType.Name == "DateOnly"&&sourceType==typeof(string))
|
||||
{
|
||||
var type = Type.GetType("System.DateOnly", true, true);
|
||||
var method = type.GetMethods().FirstOrDefault(it => it.GetParameters().Length == 1 && it.Name == "FromDateTime");
|
||||
return method.Invoke(null, new object[] {Convert.ToDateTime(value)});
|
||||
}
|
||||
var destinationConverter = TypeDescriptor.GetConverter(destinationType);
|
||||
if (destinationConverter != null && destinationConverter.CanConvertFrom(value.GetType()))
|
||||
return destinationConverter.ConvertFrom(null, culture, value);
|
||||
|
Loading…
Reference in New Issue
Block a user