mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
@ -73,7 +73,7 @@ namespace FreeSql.PostgreSQL
|
||||
else if (param is TimeOnly || param is TimeOnly?)
|
||||
{
|
||||
var ts = (TimeOnly)param;
|
||||
return $"'{ts.Hour}:{ts.Minute}:{ts.Second}.{ts.Millisecond}'";
|
||||
return $"'{ts.Hour}:{ts.Minute}:{ts.Second}'";
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace FreeSql.PostgreSQL
|
||||
{ typeof(DateTime).FullName, CsToDb.New(NpgsqlDbType.Timestamp, "timestamp", "timestamp NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?).FullName, CsToDb.New(NpgsqlDbType.Timestamp, "timestamp", "timestamp", false, true, null) },
|
||||
|
||||
#if net60
|
||||
{ typeof(TimeOnly).FullName, CsToDb.New(NpgsqlDbType.Time, "time", "time NOT NULL", false, false, 0) },{ typeof(TimeOnly?).FullName, CsToDb.New(NpgsqlDbType.Time, "time", "time", false, true, null) },
|
||||
{ typeof(TimeOnly).FullName, CsToDb.New(NpgsqlDbType.Time, "time", "time NOT NULL", false, false, TimeOnly.MinValue) },{ typeof(TimeOnly?).FullName, CsToDb.New(NpgsqlDbType.Time, "time", "time", false, true, null) },
|
||||
{ typeof(DateOnly).FullName, CsToDb.New(NpgsqlDbType.Date, "date", "date NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateOnly?).FullName, CsToDb.New(NpgsqlDbType.Date, "date", "date", false, true, null) },
|
||||
#endif
|
||||
|
||||
|
@ -26,6 +26,10 @@ namespace FreeSql.PostgreSQL
|
||||
{
|
||||
if (Interlocked.Exchange(ref _firstInit, 0) == 1) //不能放在 static ctor .NetFramework 可能报初始化类型错误
|
||||
{
|
||||
#if net60
|
||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(DateOnly)] = true;
|
||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(TimeOnly)] = true;
|
||||
#endif
|
||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BigInteger)] = true;
|
||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BitArray)] = true;
|
||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(NpgsqlPoint)] = true;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user