Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Efcore.Pg
提交
e1f93499
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 搜索 >>
提交
e1f93499
编写于
11月 09, 2022
作者:
S
Shay Rojansky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Suppress Npgsql obsoletion warnings
Global type mapping, connection-based auth callbacks
上级
97d2f374
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
32 addition
and
14 deletion
+32
-14
src/EFCore.PG.NTS/Extensions/NpgsqlNetTopologySuiteDbContextOptionsBuilderExtensions.cs
...pgsqlNetTopologySuiteDbContextOptionsBuilderExtensions.cs
+3
-1
src/EFCore.PG.NodaTime/Extensions/NpgsqlNodaTimeDbContextOptionsBuilderExtensions.cs
...nsions/NpgsqlNodaTimeDbContextOptionsBuilderExtensions.cs
+3
-1
src/EFCore.PG/Extensions/BuilderExtensions/NpgsqlModelBuilderExtensions.cs
...ensions/BuilderExtensions/NpgsqlModelBuilderExtensions.cs
+3
-4
src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs
...Core.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs
+4
-0
src/EFCore.PG/Infrastructure/NpgsqlDbContextOptionsBuilder.cs
...EFCore.PG/Infrastructure/NpgsqlDbContextOptionsBuilder.cs
+6
-7
src/EFCore.PG/Storage/Internal/Mapping/NpgsqlEnumTypeMapping.cs
...Core.PG/Storage/Internal/Mapping/NpgsqlEnumTypeMapping.cs
+2
-0
src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs
src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs
+4
-0
test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs
test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs
+2
-0
test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs
test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs
+2
-0
test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlFixture.cs
...ore.PG.FunctionalTests/Query/SpatialQueryNpgsqlFixture.cs
+3
-1
未找到文件。
src/EFCore.PG.NTS/Extensions/NpgsqlNetTopologySuiteDbContextOptionsBuilderExtensions.cs
浏览文件 @
e1f93499
...
...
@@ -25,7 +25,9 @@ public static class NpgsqlNetTopologySuiteDbContextOptionsBuilderExtensions
Check
.
NotNull
(
optionsBuilder
,
nameof
(
optionsBuilder
));
// TODO: Global-only setup at the ADO.NET level for now, optionally allow per-connection?
#pragma warning disable CS0618 // NpgsqlConnection.GlobalTypeMapper is obsolete
NpgsqlConnection
.
GlobalTypeMapper
.
UseNetTopologySuite
(
coordinateSequenceFactory
,
precisionModel
,
handleOrdinates
,
geographyAsDefault
);
#pragma warning restore CS0618
var
coreOptionsBuilder
=
((
IRelationalDbContextOptionsBuilderInfrastructure
)
optionsBuilder
).
OptionsBuilder
;
...
...
@@ -41,4 +43,4 @@ public static class NpgsqlNetTopologySuiteDbContextOptionsBuilderExtensions
return
optionsBuilder
;
}
}
\ No newline at end of file
}
src/EFCore.PG.NodaTime/Extensions/NpgsqlNodaTimeDbContextOptionsBuilderExtensions.cs
浏览文件 @
e1f93499
...
...
@@ -19,7 +19,9 @@ public static class NpgsqlNodaTimeDbContextOptionsBuilderExtensions
Check
.
NotNull
(
optionsBuilder
,
nameof
(
optionsBuilder
));
// TODO: Global-only setup at the ADO.NET level for now, optionally allow per-connection?
#pragma warning disable CS0618 // NpgsqlConnection.GlobalTypeMapper is obsolete
NpgsqlConnection
.
GlobalTypeMapper
.
UseNodaTime
();
#pragma warning restore CS0618
var
coreOptionsBuilder
=
((
IRelationalDbContextOptionsBuilderInfrastructure
)
optionsBuilder
).
OptionsBuilder
;
...
...
@@ -30,4 +32,4 @@ public static class NpgsqlNodaTimeDbContextOptionsBuilderExtensions
return
optionsBuilder
;
}
}
\ No newline at end of file
}
src/EFCore.PG/Extensions/BuilderExtensions/NpgsqlModelBuilderExtensions.cs
浏览文件 @
e1f93499
...
...
@@ -478,10 +478,9 @@ public static ModelBuilder UseIdentityColumns(this ModelBuilder modelBuilder)
INpgsqlNameTranslator
?
nameTranslator
=
null
)
where
TEnum
:
struct
,
Enum
{
if
(
nameTranslator
is
null
)
{
nameTranslator
=
NpgsqlConnection
.
GlobalTypeMapper
.
DefaultNameTranslator
;
}
#pragma warning disable CS0618 // NpgsqlConnection.GlobalTypeMapper is obsolete
nameTranslator
??=
NpgsqlConnection
.
GlobalTypeMapper
.
DefaultNameTranslator
;
#pragma warning restore CS0618
return
modelBuilder
.
HasPostgresEnum
(
schema
,
...
...
src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs
浏览文件 @
e1f93499
...
...
@@ -53,7 +53,9 @@ public class NpgsqlOptionsExtension : RelationalOptionsExtension
/// <summary>
/// The specified <see cref="ProvidePasswordCallback"/>.
/// </summary>
#pragma warning disable CS0618 // ProvidePasswordCallback is obsolete
public
virtual
ProvidePasswordCallback
?
ProvidePasswordCallback
{
get
;
private
set
;
}
#pragma warning restore CS0618
/// <summary>
/// True if reverse null ordering is enabled; otherwise, false.
...
...
@@ -250,6 +252,7 @@ public virtual NpgsqlOptionsExtension WithRemoteCertificateValidationCallback(Re
/// Returns a copy of the current instance with the specified <see cref="ProvidePasswordCallback"/>.
/// </summary>
/// <param name="callback">The specified callback.</param>
#pragma warning disable CS0618 // ProvidePasswordCallback is obsolete
public
virtual
NpgsqlOptionsExtension
WithProvidePasswordCallback
(
ProvidePasswordCallback
?
callback
)
{
var
clone
=
(
NpgsqlOptionsExtension
)
Clone
();
...
...
@@ -258,6 +261,7 @@ public virtual NpgsqlOptionsExtension WithProvidePasswordCallback(ProvidePasswor
return
clone
;
}
#pragma warning restore CS0618
#
endregion
Authentication
...
...
src/EFCore.PG/Infrastructure/NpgsqlDbContextOptionsBuilder.cs
浏览文件 @
e1f93499
...
...
@@ -108,25 +108,24 @@ internal virtual NpgsqlDbContextOptionsBuilder ReverseNullOrdering(bool reverseN
/// Configures the <see cref="DbContext"/> to use the specified <see cref="ProvideClientCertificatesCallback"/>.
/// </summary>
/// <param name="callback">The callback to use.</param>
public
virtual
NpgsqlDbContextOptionsBuilder
ProvideClientCertificatesCallback
(
ProvideClientCertificatesCallback
?
callback
)
public
virtual
NpgsqlDbContextOptionsBuilder
ProvideClientCertificatesCallback
(
ProvideClientCertificatesCallback
?
callback
)
=>
WithOption
(
e
=>
e
.
WithProvideClientCertificatesCallback
(
callback
));
/// <summary>
/// Configures the <see cref="DbContext"/> to use the specified <see cref="RemoteCertificateValidationCallback"/>.
/// </summary>
/// <param name="callback">The callback to use.</param>
public
virtual
NpgsqlDbContextOptionsBuilder
RemoteCertificateValidationCallback
(
RemoteCertificateValidationCallback
?
callback
)
public
virtual
NpgsqlDbContextOptionsBuilder
RemoteCertificateValidationCallback
(
RemoteCertificateValidationCallback
?
callback
)
=>
WithOption
(
e
=>
e
.
WithRemoteCertificateValidationCallback
(
callback
));
/// <summary>
/// Configures the <see cref="DbContext"/> to use the specified <see cref="ProvidePasswordCallback"/>.
/// </summary>
/// <param name="callback">The callback to use.</param>
public
virtual
NpgsqlDbContextOptionsBuilder
ProvidePasswordCallback
(
ProvidePasswordCallback
?
callback
)
#pragma warning disable CS0618 // ProvidePasswordCallback is obsolete
public
virtual
NpgsqlDbContextOptionsBuilder
ProvidePasswordCallback
(
ProvidePasswordCallback
?
callback
)
=>
WithOption
(
e
=>
e
.
WithProvidePasswordCallback
(
callback
));
#pragma warning restore CS0618
#
endregion
Authentication
...
...
@@ -177,4 +176,4 @@ public virtual NpgsqlDbContextOptionsBuilder EnableRetryOnFailure(ICollection<st
=>
ExecutionStrategy
(
c
=>
new
NpgsqlRetryingExecutionStrategy
(
c
,
maxRetryCount
,
maxRetryDelay
,
errorCodesToAdd
));
#
endregion
Retrying
execution
strategy
}
\ No newline at end of file
}
src/EFCore.PG/Storage/Internal/Mapping/NpgsqlEnumTypeMapping.cs
浏览文件 @
e1f93499
...
...
@@ -35,7 +35,9 @@ public class NpgsqlEnumTypeMapping : RelationalTypeMapping
throw
new
ArgumentException
(
$"Enum type mappings require a CLR enum.
{
enumType
.
FullName
}
is not an enum."
);
}
#pragma warning disable CS0618 // NpgsqlConnection.GlobalTypeMapper is obsolete
nameTranslator
??=
NpgsqlConnection
.
GlobalTypeMapper
.
DefaultNameTranslator
;
#pragma warning restore CS0618
_nameTranslator
=
nameTranslator
;
_sqlGenerationHelper
=
sqlGenerationHelper
;
...
...
src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs
浏览文件 @
e1f93499
...
...
@@ -458,14 +458,18 @@ public virtual void LoadUserDefinedTypeMappings(ISqlGenerationHelper sqlGenerati
/// </summary>
protected
virtual
void
SetupEnumMappings
(
ISqlGenerationHelper
sqlGenerationHelper
)
{
#pragma warning disable CS0618 // NpgsqlConnection.GlobalTypeMapper is obsolete
_adoUserTypeMappingsGetMethodInfo
??=
NpgsqlConnection
.
GlobalTypeMapper
.
GetType
().
GetProperty
(
"UserTypeMappings"
)?.
GetMethod
;
#pragma warning restore CS0618
if
(
_adoUserTypeMappingsGetMethodInfo
is
null
)
{
return
;
}
#pragma warning disable CS0618 // NpgsqlConnection.GlobalTypeMapper is obsolete
var
adoUserTypeMappings
=
(
IDictionary
<
string
,
IUserTypeMapping
>)
_adoUserTypeMappingsGetMethodInfo
.
Invoke
(
NpgsqlConnection
.
GlobalTypeMapper
,
Array
.
Empty
<
object
>())!;
#pragma warning restore CS0618
foreach
(
var
adoUserTypeMapping
in
adoUserTypeMappings
.
Values
.
OfType
<
IUserEnumTypeMapping
>())
{
...
...
test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs
浏览文件 @
e1f93499
...
...
@@ -977,7 +977,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
{
base
.
OnModelCreating
(
modelBuilder
,
context
);
#pragma warning disable CS0618 // NpgsqlConnection.GlobalTypeMapper is obsolete
NpgsqlConnection
.
GlobalTypeMapper
.
MapEnum
<
Mood
>();
#pragma warning restore CS0618
((
NpgsqlTypeMappingSource
)
context
.
GetService
<
ITypeMappingSource
>()).
LoadUserDefinedTypeMappings
(
context
.
GetService
<
ISqlGenerationHelper
>());
modelBuilder
.
HasPostgresEnum
(
"mood"
,
new
[]
{
"happy"
,
"sad"
});
...
...
test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs
浏览文件 @
e1f93499
...
...
@@ -233,10 +233,12 @@ public class EnumContext : PoolableDbContext
static
EnumContext
()
{
#pragma warning disable CS0618 // NpgsqlConnection.GlobalTypeMapper is obsolete
NpgsqlConnection
.
GlobalTypeMapper
.
MapEnum
<
MappedEnum
>(
"test.mapped_enum"
);
NpgsqlConnection
.
GlobalTypeMapper
.
MapEnum
<
InferredEnum
>(
"test.inferred_enum"
);
NpgsqlConnection
.
GlobalTypeMapper
.
MapEnum
<
ByteEnum
>(
"test.byte_enum"
);
NpgsqlConnection
.
GlobalTypeMapper
.
MapEnum
<
SchemaQualifiedEnum
>(
"test.schema_qualified_enum"
);
#pragma warning restore CS0618
}
public
EnumContext
(
DbContextOptions
options
)
:
base
(
options
)
{}
...
...
test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlFixture.cs
浏览文件 @
e1f93499
...
...
@@ -9,7 +9,9 @@ protected override ITestStoreFactory TestStoreFactory
protected
override
IServiceCollection
AddServices
(
IServiceCollection
serviceCollection
)
{
#pragma warning disable CS0618 // NpgsqlConnection.GlobalTypeMapper is obsolete
NpgsqlConnection
.
GlobalTypeMapper
.
UseNetTopologySuite
();
#pragma warning restore CS0618
return
base
.
AddServices
(
serviceCollection
)
.
AddEntityFrameworkNpgsqlNetTopologySuite
();
...
...
@@ -24,4 +26,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
// TODO: #1232
// protected override bool CanExecuteQueryString => true;
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录