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
a2b235de
Commit
a2b235de
authored
Feb 08, 2018
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed entityframework rename table name prefix bug. #84
parent
a2524f12
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
16 deletions
+44
-16
CAP.MySqlCapOptionsExtension.cs
src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs
+11
-1
CAP.Options.Extensions.cs
src/DotNetCore.CAP.MySql/CAP.Options.Extensions.cs
+6
-4
CAP.Options.Extensions.cs
src/DotNetCore.CAP.PostgreSql/CAP.Options.Extensions.cs
+6
-5
CAP.PostgreSqlCapOptionsExtension.cs
...tCore.CAP.PostgreSql/CAP.PostgreSqlCapOptionsExtension.cs
+9
-0
CAP.Options.Extensions.cs
src/DotNetCore.CAP.SqlServer/CAP.Options.Extensions.cs
+6
-5
CAP.SqlServerCapOptionsExtension.cs
...NetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs
+6
-1
No files found.
src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs
View file @
a2b235de
...
...
@@ -25,22 +25,32 @@ namespace DotNetCore.CAP
services
.
AddScoped
<
ICallbackPublisher
,
CapPublisher
>();
services
.
AddTransient
<
IAdditionalProcessor
,
DefaultAdditionalProcessor
>();
AddSingletionMySqlOptions
(
services
);
}
private
void
AddSingletionMySqlOptions
(
IServiceCollection
services
)
{
var
mysqlOptions
=
new
MySqlOptions
();
_configure
(
mysqlOptions
);
if
(
mysqlOptions
.
DbContextType
!=
null
)
{
services
.
AddSingleton
(
x
=>
{
using
(
var
scope
=
x
.
CreateScope
())
{
var
provider
=
scope
.
ServiceProvider
;
var
dbContext
=
(
DbContext
)
provider
.
GetService
(
mysqlOptions
.
DbContextType
);
var
dbContext
=
(
DbContext
)
provider
.
GetService
(
mysqlOptions
.
DbContextType
);
mysqlOptions
.
ConnectionString
=
dbContext
.
Database
.
GetDbConnection
().
ConnectionString
;
return
mysqlOptions
;
}
});
}
else
{
services
.
AddSingleton
(
mysqlOptions
);
}
}
}
}
\ No newline at end of file
src/DotNetCore.CAP.MySql/CAP.Options.Extensions.cs
View file @
a2b235de
...
...
@@ -16,6 +16,7 @@ namespace Microsoft.Extensions.DependencyInjection
{
if
(
configure
==
null
)
throw
new
ArgumentNullException
(
nameof
(
configure
));
options
.
RegisterExtension
(
new
MySqlCapOptionsExtension
(
configure
));
return
options
;
...
...
@@ -32,10 +33,11 @@ namespace Microsoft.Extensions.DependencyInjection
{
if
(
configure
==
null
)
throw
new
ArgumentNullException
(
nameof
(
configure
));
var
efOptions
=
new
EFOptions
{
DbContextType
=
typeof
(
TContext
)};
configure
(
efOptions
);
options
.
RegisterExtension
(
new
MySqlCapOptionsExtension
(
configure
));
options
.
RegisterExtension
(
new
MySqlCapOptionsExtension
(
x
=>
{
configure
(
x
);
x
.
DbContextType
=
typeof
(
TContext
);
}));
return
options
;
}
...
...
src/DotNetCore.CAP.PostgreSql/CAP.Options.Extensions.cs
View file @
a2b235de
...
...
@@ -24,7 +24,7 @@ namespace Microsoft.Extensions.DependencyInjection
public
static
CapOptions
UseEntityFramework
<
TContext
>(
this
CapOptions
options
)
where
TContext
:
DbContext
{
return
options
.
UseEntityFramework
<
TContext
>(
opt
=>
{
opt
.
DbContextType
=
typeof
(
TContext
);
});
return
options
.
UseEntityFramework
<
TContext
>(
opt
=>
{
});
}
public
static
CapOptions
UseEntityFramework
<
TContext
>(
this
CapOptions
options
,
Action
<
EFOptions
>
configure
)
...
...
@@ -32,10 +32,11 @@ namespace Microsoft.Extensions.DependencyInjection
{
if
(
configure
==
null
)
throw
new
ArgumentNullException
(
nameof
(
configure
));
var
efOptions
=
new
EFOptions
{
DbContextType
=
typeof
(
TContext
)};
configure
(
efOptions
);
options
.
RegisterExtension
(
new
PostgreSqlCapOptionsExtension
(
configure
));
options
.
RegisterExtension
(
new
PostgreSqlCapOptionsExtension
(
x
=>
{
configure
(
x
);
x
.
DbContextType
=
typeof
(
TContext
);
}));
return
options
;
}
...
...
src/DotNetCore.CAP.PostgreSql/CAP.PostgreSqlCapOptionsExtension.cs
View file @
a2b235de
...
...
@@ -25,10 +25,16 @@ namespace DotNetCore.CAP
services
.
AddScoped
<
ICallbackPublisher
,
CapPublisher
>();
services
.
AddTransient
<
IAdditionalProcessor
,
DefaultAdditionalProcessor
>();
AddSingletonPostgreSqlOptions
(
services
);
}
private
void
AddSingletonPostgreSqlOptions
(
IServiceCollection
services
)
{
var
postgreSqlOptions
=
new
PostgreSqlOptions
();
_configure
(
postgreSqlOptions
);
if
(
postgreSqlOptions
.
DbContextType
!=
null
)
{
services
.
AddSingleton
(
x
=>
{
using
(
var
scope
=
x
.
CreateScope
())
...
...
@@ -39,8 +45,11 @@ namespace DotNetCore.CAP
return
postgreSqlOptions
;
}
});
}
else
{
services
.
AddSingleton
(
postgreSqlOptions
);
}
}
}
}
\ No newline at end of file
src/DotNetCore.CAP.SqlServer/CAP.Options.Extensions.cs
View file @
a2b235de
...
...
@@ -24,7 +24,7 @@ namespace Microsoft.Extensions.DependencyInjection
public
static
CapOptions
UseEntityFramework
<
TContext
>(
this
CapOptions
options
)
where
TContext
:
DbContext
{
return
options
.
UseEntityFramework
<
TContext
>(
opt
=>
{
opt
.
DbContextType
=
typeof
(
TContext
);
});
return
options
.
UseEntityFramework
<
TContext
>(
opt
=>
{
});
}
public
static
CapOptions
UseEntityFramework
<
TContext
>(
this
CapOptions
options
,
Action
<
EFOptions
>
configure
)
...
...
@@ -32,10 +32,11 @@ namespace Microsoft.Extensions.DependencyInjection
{
if
(
configure
==
null
)
throw
new
ArgumentNullException
(
nameof
(
configure
));
var
efOptions
=
new
EFOptions
{
DbContextType
=
typeof
(
TContext
)};
configure
(
efOptions
);
options
.
RegisterExtension
(
new
SqlServerCapOptionsExtension
(
configure
));
options
.
RegisterExtension
(
new
SqlServerCapOptionsExtension
(
x
=>
{
configure
(
x
);
x
.
DbContextType
=
typeof
(
TContext
);
}));
return
options
;
}
...
...
src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs
View file @
a2b235de
...
...
@@ -24,6 +24,7 @@ namespace DotNetCore.CAP
services
.
AddScoped
<
ICapPublisher
,
CapPublisher
>();
services
.
AddScoped
<
ICallbackPublisher
,
CapPublisher
>();
services
.
AddTransient
<
IAdditionalProcessor
,
DefaultAdditionalProcessor
>();
AddSqlServerOptions
(
services
);
}
...
...
@@ -34,18 +35,22 @@ namespace DotNetCore.CAP
_configure
(
sqlServerOptions
);
if
(
sqlServerOptions
.
DbContextType
!=
null
)
{
services
.
AddSingleton
(
x
=>
{
using
(
var
scope
=
x
.
CreateScope
())
{
var
provider
=
scope
.
ServiceProvider
;
var
dbContext
=
(
DbContext
)
provider
.
GetService
(
sqlServerOptions
.
DbContextType
);
var
dbContext
=
(
DbContext
)
provider
.
GetService
(
sqlServerOptions
.
DbContextType
);
sqlServerOptions
.
ConnectionString
=
dbContext
.
Database
.
GetDbConnection
().
ConnectionString
;
return
sqlServerOptions
;
}
});
}
else
{
services
.
AddSingleton
(
sqlServerOptions
);
}
}
}
}
\ 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