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
2ec58064
Commit
2ec58064
authored
Aug 20, 2018
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add RelationDbTransaction and extensions
parent
8485fb2f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
0 deletions
+78
-0
RelationDbTransaction.cs
src/DotNetCore.CAP/Internal/RelationDbTransaction.cs
+38
-0
TransactionExtensions.cs
src/DotNetCore.CAP/TransactionExtensions.cs
+40
-0
No files found.
src/DotNetCore.CAP/Internal/RelationDbTransaction.cs
0 → 100644
View file @
2ec58064
// Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using
System.Data
;
namespace
DotNetCore.CAP.Internal
{
internal
class
RelationDbTransaction
:
IDbTransaction
{
private
readonly
ICapTransaction
_capTransaction
;
public
RelationDbTransaction
(
ICapTransaction
capTransaction
)
{
_capTransaction
=
capTransaction
;
var
dbTransaction
=
(
IDbTransaction
)
capTransaction
.
DbTransaction
;
Connection
=
dbTransaction
.
Connection
;
IsolationLevel
=
dbTransaction
.
IsolationLevel
;
}
public
void
Dispose
()
{
_capTransaction
.
Dispose
();
}
public
void
Commit
()
{
_capTransaction
.
Commit
();
}
public
void
Rollback
()
{
_capTransaction
.
Rollback
();
}
public
IDbConnection
Connection
{
get
;
}
public
IsolationLevel
IsolationLevel
{
get
;
}
}
}
\ No newline at end of file
src/DotNetCore.CAP/TransactionExtensions.cs
0 → 100644
View file @
2ec58064
// Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using
System.Data
;
using
DotNetCore.CAP.Internal
;
namespace
DotNetCore.CAP
{
public
static
class
TransactionExtensions
{
public
static
ICapTransaction
Begin
(
this
ICapTransaction
transaction
,
IDbTransaction
dbTransaction
,
bool
autoCommit
=
false
)
{
transaction
.
DbTransaction
=
dbTransaction
;
transaction
.
AutoCommit
=
autoCommit
;
return
transaction
;
}
public
static
IDbTransaction
JoinToTransaction
(
this
IDbTransaction
dbTransaction
,
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
{
dbTransaction
=
new
RelationDbTransaction
(
publisher
.
Transaction
.
Begin
(
dbTransaction
,
autoCommit
));
return
dbTransaction
;
}
public
static
IDbTransaction
BeginAndJoinToTransaction
(
this
IDbConnection
dbConnection
,
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
{
if
(
dbConnection
.
State
==
ConnectionState
.
Closed
)
{
dbConnection
.
Open
();
}
var
dbTransaction
=
dbConnection
.
BeginTransaction
();
return
dbTransaction
.
JoinToTransaction
(
publisher
,
autoCommit
);
}
}
}
\ No newline at end of file
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