提交 fa3c5bbf 编写于 作者: S Shay Rojansky

Mapping fixes

* Store type lookup is now case-insensitive
* Fixed NpgsqlTimeTypeMapping to map to TimeSpan, not DateTime
上级 0ac0063c
using System;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using NpgsqlTypes;
using Remotion.Linq.Clauses.Expressions;
namespace Microsoft.EntityFrameworkCore.Storage.Internal.Mapping
{
......@@ -55,10 +56,15 @@ protected override string GenerateNonNullSqlLiteral(object value)
public class NpgsqlTimeTypeMapping : NpgsqlTypeMapping
{
public NpgsqlTimeTypeMapping() : base("time without time zone", typeof(DateTime), NpgsqlDbType.Time) {}
public NpgsqlTimeTypeMapping() : base("time without time zone", typeof(TimeSpan), NpgsqlDbType.Time) {}
protected override string GenerateNonNullSqlLiteral(object value)
=> $"TIME '{(DateTime)value:HH:mm:ss.FFF}'";
{
var ts = (TimeSpan)value;
return ts.Milliseconds == 0
? $@"TIME '{(TimeSpan)value:hh\:mm\:ss}'"
: $@"TIME '{(TimeSpan)value:hh\:mm\:ss\.FFF}'";
}
}
public class NpgsqlTimeTzTypeMapping : NpgsqlTypeMapping
......
......@@ -219,7 +219,7 @@ public class NpgsqlTypeMappingSource : RelationalTypeMappingSource
{ typeof(NpgsqlRange<DateTime>), _tsrange }
};
_storeTypeMappings = new ConcurrentDictionary<string, RelationalTypeMapping>(storeTypeMappings);
_storeTypeMappings = new ConcurrentDictionary<string, RelationalTypeMapping>(storeTypeMappings, StringComparer.OrdinalIgnoreCase);
_clrTypeMappings = new ConcurrentDictionary<Type, RelationalTypeMapping>(clrTypeMappings);
if (typeof(NpgsqlConnection).Assembly.GetName().Version < new Version(3, 3))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册