Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
netcoreplus
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
netcoreplus
Commits
fefafb4b
Commit
fefafb4b
authored
May 21, 2019
by
阿星Plus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复 Plus 和 Plus.EntitiyFramework 出错问题
parent
55a8ade7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
2 deletions
+118
-2
EfCoreDbContextEntityFinder.cs
src/Plus.EntityFramework/EfCoreDbContextEntityFinder.cs
+24
-0
Plus.EntityFramework.csproj
src/Plus.EntityFramework/Plus.EntityFramework.csproj
+1
-1
AsyncLocalCurrentUnitOfWorkProvider.cs
src/Plus/Domain/Uow/AsyncLocalCurrentUnitOfWorkProvider.cs
+92
-0
Plus.csproj
src/Plus/Plus.csproj
+1
-1
No files found.
src/Plus.EntityFramework/EfCoreDbContextEntityFinder.cs
0 → 100644
View file @
fefafb4b
using
Microsoft.EntityFrameworkCore
;
using
Plus.Dependency
;
using
Plus.Domain.Entities
;
using
Plus.Reflection
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Reflection
;
namespace
Plus.EntityFramework
{
internal
class
EfCoreDbContextEntityFinder
:
IDbContextEntityFinder
,
ITransientDependency
{
public
IEnumerable
<
EntityTypeInfo
>
GetEntityTypeInfos
(
Type
dbContextType
)
{
return
from
property
in
dbContextType
.
GetProperties
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
)
where
ReflectionHelper
.
IsAssignableToGenericType
(
property
.
PropertyType
,
typeof
(
DbSet
<>))
&&
ReflectionHelper
.
IsAssignableToGenericType
(
property
.
PropertyType
.
GenericTypeArguments
[
0
],
typeof
(
IEntity
<>))
select
new
EntityTypeInfo
(
property
.
PropertyType
.
GenericTypeArguments
[
0
],
property
.
DeclaringType
);
}
}
}
\ No newline at end of file
src/Plus.EntityFramework/Plus.EntityFramework.csproj
View file @
fefafb4b
...
...
@@ -17,7 +17,7 @@
<PackageLicenseUrl>https://raw.githubusercontent.com/Meowv/.netcoreplus/master/LICENSE</PackageLicenseUrl>
<PackageTags>plus;plus.entityframework;.netcoreplus;</PackageTags>
<PackageReleaseNotes>Plus.EntityFramework</PackageReleaseNotes>
<Version>1.0.0</Version>
<Version>1.0.0
.1
</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
...
...
src/Plus/Domain/Uow/AsyncLocalCurrentUnitOfWorkProvider.cs
0 → 100644
View file @
fefafb4b
using
Castle.Core
;
using
Castle.Core.Logging
;
using
Plus.Dependency
;
using
System.Threading
;
namespace
Plus.Domain.Uow
{
public
class
AsyncLocalCurrentUnitOfWorkProvider
:
ICurrentUnitOfWorkProvider
,
ITransientDependency
{
private
class
LocalUowWrapper
{
public
IUnitOfWork
UnitOfWork
{
get
;
set
;
}
public
LocalUowWrapper
(
IUnitOfWork
unitOfWork
)
{
UnitOfWork
=
unitOfWork
;
}
}
private
static
readonly
AsyncLocal
<
LocalUowWrapper
>
AsyncLocalUow
=
new
AsyncLocal
<
LocalUowWrapper
>();
[
DoNotWire
]
public
IUnitOfWork
Current
{
get
{
return
GetCurrentUow
();
}
set
{
SetCurrentUow
(
value
);
}
}
public
ILogger
Logger
{
get
;
set
;
}
public
AsyncLocalCurrentUnitOfWorkProvider
()
{
Logger
=
NullLogger
.
Instance
;
}
private
static
IUnitOfWork
GetCurrentUow
()
{
IUnitOfWork
unitOfWork
=
AsyncLocalUow
.
Value
?.
UnitOfWork
;
if
(
unitOfWork
==
null
)
{
return
null
;
}
if
(
unitOfWork
.
IsDisposed
)
{
AsyncLocalUow
.
Value
=
null
;
return
null
;
}
return
unitOfWork
;
}
private
static
void
SetCurrentUow
(
IUnitOfWork
value
)
{
lock
(
AsyncLocalUow
)
{
if
(
value
==
null
)
{
if
(
AsyncLocalUow
.
Value
!=
null
)
{
if
(
AsyncLocalUow
.
Value
.
UnitOfWork
?.
Outer
==
null
)
{
AsyncLocalUow
.
Value
.
UnitOfWork
=
null
;
AsyncLocalUow
.
Value
=
null
;
}
else
{
AsyncLocalUow
.
Value
.
UnitOfWork
=
AsyncLocalUow
.
Value
.
UnitOfWork
.
Outer
;
}
}
}
else
if
(
AsyncLocalUow
.
Value
?.
UnitOfWork
==
null
)
{
if
(
AsyncLocalUow
.
Value
!=
null
)
{
AsyncLocalUow
.
Value
.
UnitOfWork
=
value
;
}
AsyncLocalUow
.
Value
=
new
LocalUowWrapper
(
value
);
}
else
{
value
.
Outer
=
AsyncLocalUow
.
Value
.
UnitOfWork
;
AsyncLocalUow
.
Value
.
UnitOfWork
=
value
;
}
}
}
}
}
\ No newline at end of file
src/Plus/Plus.csproj
View file @
fefafb4b
...
...
@@ -17,7 +17,7 @@
<PackageLicenseUrl>https://raw.githubusercontent.com/Meowv/.netcoreplus/master/LICENSE</PackageLicenseUrl>
<PackageTags>plus;.netcoreplus;</PackageTags>
<PackageReleaseNotes>Plus</PackageReleaseNotes>
<Version>1.0.0</Version>
<Version>1.0.0
.1
</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment