Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Efcore.Pg
提交
a1e00bd1
E
Efcore.Pg
项目概览
jobily
/
Efcore.Pg
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
a1e00bd1
编写于
7月 06, 2017
作者:
S
Shay Rojansky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bring back array scaffolding
Fixes #205
上级
0a1fd459
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
25 addition
and
13 deletion
+25
-13
src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs
...ore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs
+4
-2
src/EFCore.PG/Storage/Internal/Mapping/NpgsqlArrayTypeMapping.cs
...ore.PG/Storage/Internal/Mapping/NpgsqlArrayTypeMapping.cs
+8
-7
src/EFCore.PG/Storage/Internal/Mapping/NpgsqlTypeMapping.cs
src/EFCore.PG/Storage/Internal/Mapping/NpgsqlTypeMapping.cs
+1
-4
src/EFCore.PG/Storage/Internal/NpgsqlEFTypeMapper.cs
src/EFCore.PG/Storage/Internal/NpgsqlEFTypeMapper.cs
+10
-0
test/EFCore.PG.Design.FunctionalTests/ReverseEngineering/Expected/AllFluentApi/SpecialTypes.expected
...seEngineering/Expected/AllFluentApi/SpecialTypes.expected
+1
-0
test/EFCore.PG.Design.FunctionalTests/ReverseEngineering/Expected/Attributes/SpecialTypes.expected
...erseEngineering/Expected/Attributes/SpecialTypes.expected
+1
-0
未找到文件。
src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs
浏览文件 @
a1e00bd1
...
...
@@ -242,8 +242,10 @@ void GetColumns()
// Base (regular), is the default
break
;
case
'a'
:
column
[
NpgsqlAnnotationNames
.
PostgresTypeType
]
=
PostgresTypeType
.
Array
;
column
[
NpgsqlAnnotationNames
.
ElementDataType
]
=
elemDataType
;
// PG array types in pg_type start with underscores (_int for array of int), but the type name
// PG accepts when creating columns is int[], translate.
if
(
column
.
StoreType
.
StartsWith
(
"_"
))
column
.
StoreType
=
column
.
StoreType
.
Substring
(
1
)
+
"[]"
;
break
;
case
'r'
:
column
[
NpgsqlAnnotationNames
.
PostgresTypeType
]
=
PostgresTypeType
.
Range
;
...
...
src/EFCore.PG/Storage/Internal/Mapping/NpgsqlArrayTypeMapping.cs
浏览文件 @
a1e00bd1
...
...
@@ -34,20 +34,21 @@ namespace Microsoft.EntityFrameworkCore.Storage.Internal
{
public
sealed
class
NpgsqlArrayTypeMapping
:
NpgsqlTypeMapping
{
//readonly NpgsqlDbType? _npgsqlDbType;
public
RelationalTypeMapping
ElementMapping
{
get
;
private
set
;
}
internal
NpgsqlArrayTypeMapping
(
Type
arrayClrType
,
RelationalTypeMapping
elementMapping
)
:
base
(
'_'
+
elementMapping
.
StoreType
,
arrayClrType
)
:
base
(
elementMapping
.
StoreType
+
"[]"
,
arrayClrType
)
{
ElementMapping
=
elementMapping
;
//if (elementMapping
.NpgsqlDbType.HasValue)
// _npgsqlDbType = elementMapping
.NpgsqlDbType.Value | NpgsqlTypes.NpgsqlDbType.Array;
if
(
elementMapping
is
NpgsqlTypeMapping
m
&&
m
.
NpgsqlDbType
.
HasValue
)
NpgsqlDbType
=
m
.
NpgsqlDbType
.
Value
|
NpgsqlTypes
.
NpgsqlDbType
.
Array
;
}
//public override RelationalTypeMapping CreateCopy(string storeType, int? size)
// => new NpgsqlArrayTypeMapping(storeType, DbType);
public
override
RelationalTypeMapping
Clone
(
string
storeType
,
int
?
size
)
=>
new
NpgsqlTypeMapping
(
storeType
,
ClrType
,
NpgsqlDbType
);
protected
override
string
GenerateNonNullSqlLiteral
(
object
value
)
=>
throw
new
NotSupportedException
(
"Can't generate array literals (yet)"
);
}
}
src/EFCore.PG/Storage/Internal/Mapping/NpgsqlTypeMapping.cs
浏览文件 @
a1e00bd1
...
...
@@ -15,12 +15,9 @@ public class NpgsqlTypeMapping : RelationalTypeMapping
{
public
NpgsqlDbType
?
NpgsqlDbType
{
get
;
protected
set
;
}
readonly
Type
_type
;
internal
NpgsqlTypeMapping
([
NotNull
]
string
storeType
,
[
NotNull
]
Type
clrType
,
NpgsqlDbType
?
npgsqlDbType
=
null
)
:
base
(
storeType
,
clrType
,
unicode
:
false
,
size
:
null
,
dbType
:
null
)
{
_type
=
clrType
;
NpgsqlDbType
=
npgsqlDbType
;
}
...
...
@@ -31,6 +28,6 @@ protected override void ConfigureParameter([NotNull] DbParameter parameter)
}
public
override
RelationalTypeMapping
Clone
(
string
storeType
,
int
?
size
)
=>
new
NpgsqlTypeMapping
(
storeType
,
_t
ype
,
NpgsqlDbType
);
=>
new
NpgsqlTypeMapping
(
storeType
,
ClrT
ype
,
NpgsqlDbType
);
}
}
src/EFCore.PG/Storage/Internal/NpgsqlEFTypeMapper.cs
浏览文件 @
a1e00bd1
...
...
@@ -73,6 +73,7 @@ public NpgsqlEFTypeMapper([NotNull] RelationalTypeMapperDependencies dependencie
StringMapper
=
new
NpgsqlStringRelationalTypeMapper
();
AddCustomizedMappings
();
AddArrayStoreMappings
();
}
void
AddCustomizedMappings
()
...
...
@@ -112,6 +113,15 @@ void AddCustomizedMappings()
_baseClrMappings
[
typeof
(
uint
)]
=
new
NpgsqlBaseTypeMapping
(
"oid"
,
typeof
(
uint
),
NpgsqlDbType
.
Oid
);
}
void
AddArrayStoreMappings
()
{
foreach
(
var
elementMapping
in
_storeTypeMappings
.
Values
.
ToList
())
{
var
arrayMapping
=
new
NpgsqlArrayTypeMapping
(
elementMapping
.
ClrType
.
MakeArrayType
(),
elementMapping
);
_storeTypeMappings
[
arrayMapping
.
StoreType
]
=
arrayMapping
;
}
}
protected
override
string
GetColumnType
(
IProperty
property
)
=>
property
.
Npgsql
().
ColumnType
;
protected
override
IReadOnlyDictionary
<
Type
,
RelationalTypeMapping
>
GetClrTypeMappings
()
...
...
test/EFCore.PG.Design.FunctionalTests/ReverseEngineering/Expected/AllFluentApi/SpecialTypes.expected
浏览文件 @
a1e00bd1
...
...
@@ -10,5 +10,6 @@ namespace E2ETest.Namespace
public int SpecialTypesId { get; set; }
public IPAddress IpAddress { get; set; }
public PhysicalAddress MacAddress { get; set; }
public int[] IntArray { get; set; }
}
}
test/EFCore.PG.Design.FunctionalTests/ReverseEngineering/Expected/Attributes/SpecialTypes.expected
浏览文件 @
a1e00bd1
...
...
@@ -13,5 +13,6 @@ namespace E2ETest.Namespace
public int SpecialTypesId { get; set; }
public IPAddress IpAddress { get; set; }
public PhysicalAddress MacAddress { get; set; }
public int[] IntArray { get; set; }
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录