mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-25 01:19:37 +08:00
Code optimization
This commit is contained in:
parent
8bba55b30c
commit
ddfda2d463
@ -44,12 +44,11 @@ namespace SqlSugar
|
||||
var type = UtilMethods.GetUnderType(value.GetType());
|
||||
if (type == UtilConstants.DateType)
|
||||
{
|
||||
var date = value.ObjToDate();
|
||||
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
|
||||
{
|
||||
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
|
||||
}
|
||||
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
||||
return GetDateTimeString(value);
|
||||
}
|
||||
else if (value is DateTimeOffset)
|
||||
{
|
||||
return GetDateTimeOffsetString(value);
|
||||
}
|
||||
else if (type == UtilConstants.ByteArrayType)
|
||||
{
|
||||
@ -84,6 +83,27 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private object GetDateTimeOffsetString(object value)
|
||||
{
|
||||
var date = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value);
|
||||
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
|
||||
{
|
||||
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
|
||||
}
|
||||
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
||||
}
|
||||
|
||||
private object GetDateTimeString(object value)
|
||||
{
|
||||
var date = value.ObjToDate();
|
||||
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
|
||||
{
|
||||
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
|
||||
}
|
||||
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
||||
}
|
||||
|
||||
private string GetString(object value)
|
||||
{
|
||||
var result = value.ToString();
|
||||
|
@ -106,12 +106,11 @@ namespace SqlSugar
|
||||
var type = UtilMethods.GetUnderType(value.GetType());
|
||||
if (type == UtilConstants.DateType)
|
||||
{
|
||||
var date = value.ObjToDate();
|
||||
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
|
||||
{
|
||||
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
|
||||
}
|
||||
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
||||
return GetDateTimeString(value);
|
||||
}
|
||||
else if (value is DateTimeOffset)
|
||||
{
|
||||
return GetDateTimeOffsetString(value);
|
||||
}
|
||||
else if (type == UtilConstants.ByteArrayType)
|
||||
{
|
||||
@ -154,6 +153,27 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private object GetDateTimeString(object value)
|
||||
{
|
||||
var date = value.ObjToDate();
|
||||
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
|
||||
{
|
||||
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
|
||||
}
|
||||
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
||||
}
|
||||
|
||||
private object GetDateTimeOffsetString(object value)
|
||||
{
|
||||
var date = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value);
|
||||
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
|
||||
{
|
||||
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
|
||||
}
|
||||
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
||||
}
|
||||
|
||||
private string GetString(object value)
|
||||
{
|
||||
var result = value.ToString();
|
||||
|
Loading…
Reference in New Issue
Block a user