- 修复 DateOnly/TimeOnly 映射问题;#1868 #1855 #1763 #939 #991

This commit is contained in:
2881099
2024-08-21 02:55:16 +08:00
parent 486015a3c2
commit 2334fe2450
36 changed files with 584 additions and 76 deletions

View File

@ -69,6 +69,12 @@ namespace FreeSql.PostgreSQL
} },
{ typeof((IPAddress Address, int Subnet)[]).FullName, a => getParamterArrayValue(typeof((IPAddress Address, int Subnet)), a, (IPAddress.Any, 0)) },
{ typeof((IPAddress Address, int Subnet)?[]).FullName, a => getParamterArrayValue(typeof((IPAddress Address, int Subnet)?), a, null) },
#if net60
{ typeof(DateOnly[]).FullName, a => getParamterArrayValue(typeof(DateTime), a, null) },
{ typeof(DateOnly?[]).FullName, a => getParamterArrayValue(typeof(DateTime?), a, null) },
{ typeof(TimeOnly[]).FullName, a => getParamterArrayValue(typeof(TimeSpan), a, null) },
{ typeof(TimeOnly?[]).FullName, a => getParamterArrayValue(typeof(TimeSpan?), a, null) },
#endif
};
static object getParamterValue(Type type, object value, int level = 0)
{
@ -87,6 +93,10 @@ namespace FreeSql.PostgreSQL
}
if (type.IsNullableType()) type = type.GenericTypeArguments.First();
if (type.IsEnum) return (int)value;
#if net60
if (type == typeof(DateOnly)) return ((DateOnly)value).ToDateTime(TimeOnly.MinValue);
if (type == typeof(TimeOnly)) return ((TimeOnly)value).ToTimeSpan();
#endif
if (dicGetParamterValue.TryGetValue(type.FullName, out var trydic)) return trydic(value);
return value;
}