mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 优化 TypeHandlers 支持 DateTime 映射规则;#1634
This commit is contained in:
@ -51,6 +51,9 @@ namespace FreeSql.Custom
|
||||
{
|
||||
if (value == null) return "NULL";
|
||||
if (value.Equals(DateTime.MinValue) == true) value = new DateTime(1970, 1, 1);
|
||||
|
||||
if (value is DateTime && Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(value)?.ToString();
|
||||
if (value is DateTime? && Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler2)) return typeHandler2.Serialize(value)?.ToString();
|
||||
return string.Concat("'", ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||
}
|
||||
public virtual string TimeSpanRawSql(object value) => value == null ? "NULL" : ((TimeSpan)value).TotalSeconds.ToString();
|
||||
|
Reference in New Issue
Block a user