Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
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
CAP
Commits
5df6c76c
Commit
5df6c76c
authored
Dec 05, 2019
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix SQL Server tranaction error in entityframework. #402
parent
45286ea2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
11 deletions
+2
-11
ICapTransaction.SqlServer.cs
src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs
+2
-11
No files found.
src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs
View file @
5df6c76c
...
@@ -11,29 +11,22 @@ using DotNetCore.CAP.Persistence;
...
@@ -11,29 +11,22 @@ using DotNetCore.CAP.Persistence;
using
DotNetCore.CAP.SqlServer.Diagnostics
;
using
DotNetCore.CAP.SqlServer.Diagnostics
;
using
DotNetCore.CAP.Transport
;
using
DotNetCore.CAP.Transport
;
using
Microsoft.Data.SqlClient
;
using
Microsoft.Data.SqlClient
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Storage
;
using
Microsoft.EntityFrameworkCore.Storage
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Options
;
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
namespace
DotNetCore.CAP
{
{
public
class
SqlServerCapTransaction
:
CapTransactionBase
public
class
SqlServerCapTransaction
:
CapTransactionBase
{
{
private
readonly
DbContext
_dbContext
;
private
readonly
DiagnosticProcessorObserver
_diagnosticProcessor
;
private
readonly
DiagnosticProcessorObserver
_diagnosticProcessor
;
public
SqlServerCapTransaction
(
public
SqlServerCapTransaction
(
IDispatcher
dispatcher
,
IDispatcher
dispatcher
,
IServiceProvider
serviceProvide
r
)
:
base
(
dispatcher
)
DiagnosticProcessorObserver
diagnosticProcesso
r
)
:
base
(
dispatcher
)
{
{
var
sqlServerOptions
=
serviceProvider
.
GetService
<
IOptions
<
SqlServerOptions
>>().
Value
;
_diagnosticProcessor
=
diagnosticProcessor
;
if
(
sqlServerOptions
.
DbContextType
!=
null
)
_dbContext
=
serviceProvider
.
GetService
(
sqlServerOptions
.
DbContextType
)
as
DbContext
;
_diagnosticProcessor
=
serviceProvider
.
GetRequiredService
<
DiagnosticProcessorObserver
>();
}
}
protected
override
void
AddToSent
(
MediumMessage
msg
)
protected
override
void
AddToSent
(
MediumMessage
msg
)
...
@@ -76,7 +69,6 @@ namespace DotNetCore.CAP
...
@@ -76,7 +69,6 @@ namespace DotNetCore.CAP
dbTransaction
.
Commit
();
dbTransaction
.
Commit
();
break
;
break
;
case
IDbContextTransaction
dbContextTransaction
:
case
IDbContextTransaction
dbContextTransaction
:
_dbContext
?.
SaveChanges
();
dbContextTransaction
.
Commit
();
dbContextTransaction
.
Commit
();
break
;
break
;
}
}
...
@@ -93,7 +85,6 @@ namespace DotNetCore.CAP
...
@@ -93,7 +85,6 @@ namespace DotNetCore.CAP
dbTransaction
.
Commit
();
dbTransaction
.
Commit
();
break
;
break
;
case
IDbContextTransaction
dbContextTransaction
:
case
IDbContextTransaction
dbContextTransaction
:
await
_dbContext
.
SaveChangesAsync
(
cancellationToken
);
await
dbContextTransaction
.
CommitAsync
(
cancellationToken
);
await
dbContextTransaction
.
CommitAsync
(
cancellationToken
);
break
;
break
;
}
}
...
...
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