mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
- 优化 TypeHandlers 支持 Enum 枚举映射规则;#1634
This commit is contained in:
@ -102,14 +102,14 @@ namespace FreeSql.GBase
|
||||
}
|
||||
if (type == typeof(DateTime))
|
||||
{
|
||||
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(value)?.ToString();
|
||||
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return FormatSql("{0}", typeHandler.Serialize(value), 1);
|
||||
if (col?.DbPrecision > 0)
|
||||
return string.Concat("'", ((DateTime)value).ToString($"yyyy-MM-dd HH:mm:ss.{"f".PadRight(col.DbPrecision, 'f')}"), "'");
|
||||
return string.Concat("'", ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||
}
|
||||
if (type == typeof(DateTime?))
|
||||
{
|
||||
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(value)?.ToString();
|
||||
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return FormatSql("{0}", typeHandler.Serialize(value), 1);
|
||||
if (col?.DbPrecision > 0)
|
||||
return string.Concat("'", ((DateTime)value).ToString($"yyyy-MM-dd HH:mm:ss.{"f".PadRight(col.DbPrecision, 'f')}"), "'");
|
||||
return string.Concat("'", ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||
|
Reference in New Issue
Block a user