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
3ec25195
Commit
3ec25195
authored
Jul 14, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add dbcontext type to options.
parent
a04076d2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
9 deletions
+13
-9
CAP.BuilderExtensions.cs
...tNetCore.CAP.EntityFrameworkCore/CAP.BuilderExtensions.cs
+2
-1
CapDbContext.cs
src/DotNetCore.CAP.EntityFrameworkCore/CapDbContext.cs
+3
-2
CapPublisherExtensions.cs
...NetCore.CAP.EntityFrameworkCore/CapPublisherExtensions.cs
+1
-1
EFStorageConnection.cs
...DotNetCore.CAP.EntityFrameworkCore/EFStorageConnection.cs
+5
-5
SqlServerOptions.cs
src/DotNetCore.CAP.EntityFrameworkCore/SqlServerOptions.cs
+2
-0
No files found.
src/DotNetCore.CAP.EntityFrameworkCore/CAP.BuilderExtensions.cs
View file @
3ec25195
...
@@ -28,6 +28,7 @@ namespace Microsoft.Extensions.DependencyInjection
...
@@ -28,6 +28,7 @@ namespace Microsoft.Extensions.DependencyInjection
builder
.
Services
.
Configure
(
actionOptions
);
builder
.
Services
.
Configure
(
actionOptions
);
var
sqlServerOptions
=
new
SqlServerOptions
();
var
sqlServerOptions
=
new
SqlServerOptions
();
sqlServerOptions
.
DbContextType
=
typeof
(
TContext
);
actionOptions
(
sqlServerOptions
);
actionOptions
(
sqlServerOptions
);
builder
.
Services
.
AddSingleton
(
sqlServerOptions
);
builder
.
Services
.
AddSingleton
(
sqlServerOptions
);
...
@@ -44,6 +45,6 @@ namespace Microsoft.Extensions.DependencyInjection
...
@@ -44,6 +45,6 @@ namespace Microsoft.Extensions.DependencyInjection
return
builder
;
return
builder
;
}
}
}
}
}
}
\ No newline at end of file
src/DotNetCore.CAP.EntityFrameworkCore/CapDbContext.cs
View file @
3ec25195
...
@@ -28,8 +28,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
...
@@ -28,8 +28,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
/// <summary>
/// <summary>
/// Gets or sets the <see cref="CapSentMessage"/> of Messages.
/// Gets or sets the <see cref="CapSentMessage"/> of Messages.
/// </summary>
/// </summary>
public
DbSet
<
CapSentMessage
>
CapSentMessages
{
get
;
set
;
}
public
DbSet
<
CapSentMessage
>
CapSentMessages
{
get
;
set
;
}
public
DbSet
<
CapQueue
>
CapQueue
{
get
;
set
;
}
public
DbSet
<
CapQueue
>
CapQueue
{
get
;
set
;
}
...
@@ -48,6 +47,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
...
@@ -48,6 +47,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
/// </param>
/// </param>
protected
override
void
OnModelCreating
(
ModelBuilder
modelBuilder
)
protected
override
void
OnModelCreating
(
ModelBuilder
modelBuilder
)
{
{
//_sqlServerOptions = new SqlServerOptions();
modelBuilder
.
HasDefaultSchema
(
_sqlServerOptions
.
Schema
);
modelBuilder
.
HasDefaultSchema
(
_sqlServerOptions
.
Schema
);
modelBuilder
.
Entity
<
CapSentMessage
>(
b
=>
modelBuilder
.
Entity
<
CapSentMessage
>(
b
=>
...
@@ -67,6 +67,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
...
@@ -67,6 +67,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
protected
override
void
OnConfiguring
(
DbContextOptionsBuilder
optionsBuilder
)
protected
override
void
OnConfiguring
(
DbContextOptionsBuilder
optionsBuilder
)
{
{
// optionsBuilder.UseSqlServer("Server=192.168.2.206;Initial Catalog=Test;User Id=cmswuliu;Password=h7xY81agBn*Veiu3;MultipleActiveResultSets=True");
}
}
}
}
}
}
\ No newline at end of file
src/DotNetCore.CAP.EntityFrameworkCore/CapPublisherExtensions.cs
View file @
3ec25195
...
@@ -32,7 +32,7 @@ namespace DotNetCore.CAP
...
@@ -32,7 +32,7 @@ namespace DotNetCore.CAP
}
}
public
static
async
Task
Publish
(
this
ICapPublisher
publisher
,
string
topic
,
string
content
,
IDbConnection
connection
,
IDbTransaction
transaction
)
public
static
async
Task
Publish
(
this
ICapPublisher
publisher
,
string
topic
,
string
content
,
IDbConnection
connection
,
IDbTransaction
transaction
)
{
{
var
message
=
new
CapSentMessage
var
message
=
new
CapSentMessage
{
{
...
...
src/DotNetCore.CAP.EntityFrameworkCore/EFStorageConnection.cs
View file @
3ec25195
...
@@ -108,14 +108,14 @@ WHERE StateName = '{StatusName.Enqueued}'";
...
@@ -108,14 +108,14 @@ WHERE StateName = '{StatusName.Enqueued}'";
private
async
Task
<
IFetchedMessage
>
FetchNextMessageCoreAsync
(
string
sql
,
object
args
=
null
)
private
async
Task
<
IFetchedMessage
>
FetchNextMessageCoreAsync
(
string
sql
,
object
args
=
null
)
{
{
FetchedMessage
fetched
Job
=
null
;
FetchedMessage
fetched
Message
=
null
;
var
connection
=
_context
.
GetDbConnection
();
var
connection
=
_context
.
GetDbConnection
();
var
transaction
=
_context
.
Database
.
CurrentTransaction
;
var
transaction
=
_context
.
Database
.
CurrentTransaction
;
transaction
=
transaction
??
await
_context
.
Database
.
BeginTransactionAsync
(
IsolationLevel
.
ReadCommitted
);
transaction
=
transaction
??
await
_context
.
Database
.
BeginTransactionAsync
(
IsolationLevel
.
ReadCommitted
);
try
try
{
{
fetched
Job
=
fetched
Message
=
(
await
connection
.
QueryAsync
<
FetchedMessage
>(
sql
,
args
,
transaction
.
GetDbTransaction
()))
(
await
connection
.
QueryAsync
<
FetchedMessage
>(
sql
,
args
,
transaction
.
GetDbTransaction
()))
.
FirstOrDefault
();
.
FirstOrDefault
();
}
}
...
@@ -125,7 +125,7 @@ WHERE StateName = '{StatusName.Enqueued}'";
...
@@ -125,7 +125,7 @@ WHERE StateName = '{StatusName.Enqueued}'";
throw
;
throw
;
}
}
if
(
fetched
Job
==
null
)
if
(
fetched
Message
==
null
)
{
{
transaction
.
Rollback
();
transaction
.
Rollback
();
transaction
.
Dispose
();
transaction
.
Dispose
();
...
@@ -133,8 +133,8 @@ WHERE StateName = '{StatusName.Enqueued}'";
...
@@ -133,8 +133,8 @@ WHERE StateName = '{StatusName.Enqueued}'";
}
}
return
new
EFFetchedMessage
(
return
new
EFFetchedMessage
(
fetched
Job
.
MessageId
,
fetched
Message
.
MessageId
,
fetched
Job
.
Type
,
fetched
Message
.
Type
,
connection
,
connection
,
transaction
);
transaction
);
}
}
...
...
src/DotNetCore.CAP.EntityFrameworkCore/SqlServerOptions.cs
View file @
3ec25195
...
@@ -31,5 +31,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
...
@@ -31,5 +31,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
/// Default is <see cref="DefaultMigrationsHistoryTableName"/>.
/// Default is <see cref="DefaultMigrationsHistoryTableName"/>.
/// </summary>
/// </summary>
public
string
MigrationsHistoryTableName
{
get
;
set
;
}
=
DefaultMigrationsHistoryTableName
;
public
string
MigrationsHistoryTableName
{
get
;
set
;
}
=
DefaultMigrationsHistoryTableName
;
public
Type
DbContextType
{
get
;
set
;
}
}
}
}
}
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