Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Efcore.Pg
提交
34e3a149
E
Efcore.Pg
项目概览
jobily
/
Efcore.Pg
10 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
Efcore.Pg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
34e3a149
编写于
8月 13, 2020
作者:
S
Shay Rojansky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix mapping of PG money
Fixes #1467 (cherry picked from commit
a213f868
)
上级
ad4abdb0
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
44 addition
and
16 deletion
+44
-16
src/EFCore.PG/Storage/Internal/Mapping/NpgsqlMoneyTypeMapping.cs
...ore.PG/Storage/Internal/Mapping/NpgsqlMoneyTypeMapping.cs
+23
-0
src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs
src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs
+1
-1
test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs
test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs
+19
-2
test/EFCore.PG.FunctionalTests/TestModels/Northwind/NorthwindNpgsqlContext.cs
...ionalTests/TestModels/Northwind/NorthwindNpgsqlContext.cs
+1
-13
未找到文件。
src/EFCore.PG/Storage/Internal/Mapping/NpgsqlMoneyTypeMapping.cs
0 → 100644
浏览文件 @
34e3a149
using
System
;
using
System.Data.Common
;
using
Microsoft.EntityFrameworkCore.Storage
;
using
NpgsqlTypes
;
namespace
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping
{
public
class
NpgsqlMoneyTypeMapping
:
DecimalTypeMapping
{
public
NpgsqlMoneyTypeMapping
()
:
base
(
"money"
,
System
.
Data
.
DbType
.
Currency
)
{}
protected
NpgsqlMoneyTypeMapping
(
RelationalTypeMappingParameters
parameters
)
:
base
(
parameters
)
{
}
protected
override
RelationalTypeMapping
Clone
(
RelationalTypeMappingParameters
parameters
)
=>
new
NpgsqlMoneyTypeMapping
();
protected
override
string
GenerateNonNullSqlLiteral
(
object
value
)
=>
base
.
GenerateNonNullSqlLiteral
(
value
)
+
"::money"
;
}
}
src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs
浏览文件 @
34e3a149
...
...
@@ -34,7 +34,7 @@ public class NpgsqlTypeMappingSource : RelationalTypeMappingSource
readonly
FloatTypeMapping
_float4
=
new
FloatTypeMapping
(
"real"
,
DbType
.
Single
);
readonly
DoubleTypeMapping
_float8
=
new
DoubleTypeMapping
(
"double precision"
,
DbType
.
Double
);
readonly
DecimalTypeMapping
_numeric
=
new
DecimalTypeMapping
(
"numeric"
,
DbType
.
Decimal
);
readonly
DecimalTypeMapping
_money
=
new
DecimalTypeMapping
(
"money"
);
readonly
NpgsqlMoneyTypeMapping
_money
=
new
NpgsqlMoneyTypeMapping
(
);
readonly
GuidTypeMapping
_uuid
=
new
GuidTypeMapping
(
"uuid"
,
DbType
.
Guid
);
readonly
ShortTypeMapping
_int2
=
new
ShortTypeMapping
(
"smallint"
,
DbType
.
Int16
);
readonly
ByteTypeMapping
_int2Byte
=
new
ByteTypeMapping
(
"smallint"
,
DbType
.
Byte
);
...
...
test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs
浏览文件 @
34e3a149
...
...
@@ -459,7 +459,7 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types()
@p8='2016-01-02T11:11:12' (DbType = DateTimeOffset)
@p9='0001-01-01T12:00:00.0000000+02:00' (DbType = Object)
@p10='101.7'
@p11='81.1'
@p11='81.1'
(DbType = Currency)
@p12='103.9'
@p13='System.Collections.Generic.Dictionary`2[System.String,System.String]' (Nullable = false) (DbType = Object)
@p14='85.5'
...
...
@@ -869,7 +869,7 @@ public void Sum_Conversions()
{
using
var
context
=
CreateContext
();
// PostgreSQL SUM() returns numeric for bigint input, bigint for int/smallint in
u
ts.
// PostgreSQL SUM() returns numeric for bigint input, bigint for int/smallint ints.
// Make sure the proper conversion is done
var
sum1
=
context
.
Set
<
MappedDataTypes
>().
Sum
(
m
=>
m
.
LongAsBigint
);
var
sum2
=
context
.
Set
<
MappedDataTypes
>().
Sum
(
m
=>
m
.
Int
);
...
...
@@ -886,6 +886,23 @@ public void Sum_Conversions()
FROM ""MappedDataTypes"" AS m"
);
}
[
ConditionalFact
]
public
void
Money_compare_constant
()
{
using
var
context
=
CreateContext
();
_
=
context
.
Set
<
MappedDataTypes
>().
Where
(
m
=>
m
.
DecimalAsMoney
>
3
).
ToList
();
}
[
ConditionalFact
]
public
void
Money_compare_parameter
()
{
using
var
context
=
CreateContext
();
var
money
=
3
m
;
_
=
context
.
Set
<
MappedDataTypes
>().
Where
(
m
=>
m
.
DecimalAsMoney
>
money
).
ToList
();
}
void
AssertSql
(
params
string
[]
expected
)
=>
Fixture
.
TestSqlLoggerFactory
.
AssertBaseline
(
expected
);
...
...
test/EFCore.PG.FunctionalTests/TestModels/Northwind/NorthwindNpgsqlContext.cs
浏览文件 @
34e3a149
...
...
@@ -27,20 +27,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder
.
Entity
<
Order
>()
.
Property
(
o
=>
o
.
EmployeeID
)
.
HasColumnType
(
"int4"
);
modelBuilder
.
Entity
<
OrderDetail
>()
.
Property
(
od
=>
od
.
UnitPrice
)
.
HasColumnType
(
"money"
);
modelBuilder
.
Entity
<
Product
>(
b
=>
{
b
.
Property
(
p
=>
p
.
UnitPrice
).
HasColumnType
(
"money"
);
b
.
Property
(
p
=>
p
.
UnitsInStock
).
HasColumnType
(
"int2"
);
});
modelBuilder
.
Entity
<
MostExpensiveProduct
>()
.
Property
(
p
=>
p
.
UnitPrice
)
.
HasColumnType
(
"money"
);
modelBuilder
.
Entity
<
Product
>(
b
=>
b
.
Property
(
p
=>
p
.
UnitsInStock
).
HasColumnType
(
"int2"
));
#pragma warning disable CS0618 // Type or member is obsolete
modelBuilder
.
Query
<
CustomerView
>().
HasNoKey
().
ToQuery
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录