同步OpenAuth.Core,增加多数据源

This commit is contained in:
ÂëÉñ
2020-12-29 23:52:06 +08:00
committed by yubaolee
parent 20a717b2e6
commit 304a0eb54d
40 changed files with 119 additions and 83 deletions

View File

@@ -22,8 +22,8 @@ namespace OpenAuth.Repository.Test
var serviceCollection = GetService();
serviceCollection.AddMemoryCache();
serviceCollection.AddOptions();
serviceCollection.AddScoped(typeof(IRepository<>), typeof(BaseRepository<>));
serviceCollection.AddScoped(typeof(IUnitWork), typeof(UnitWork));
serviceCollection.AddScoped(typeof(IRepository<,>), typeof(BaseRepository<,>));
serviceCollection.AddScoped(typeof(IUnitWork<>), typeof(UnitWork<>));
serviceCollection.AddDbContext<OpenAuthDBContext>(options =>
options.UseSqlServer("Data Source=.;Initial Catalog=OpenAuthDB;User=sa;Password=000000;Integrated Security=True"));

View File

@@ -83,7 +83,7 @@ namespace OpenAuth.Repository.Test
Console.WriteLine(account);
var repository = _autofacServiceProvider.GetService<IRepository<User>>();
var repository = _autofacServiceProvider.GetService<IRepository<User,OpenAuthDBContext>>();
//新增
repository.Add(new User

View File

@@ -17,7 +17,7 @@ namespace OpenAuth.Repository.Test
[Test]
public void NormalSubmit()
{
var unitWork = _autofacServiceProvider.GetService<IUnitWork>();
var unitWork = _autofacServiceProvider.GetService<IUnitWork<OpenAuthDBContext>>();
unitWork.ExecuteWithTransaction(() =>
{
var account = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss");
@@ -33,7 +33,7 @@ namespace OpenAuth.Repository.Test
[Test]
public void SubmitWithRollback()
{
var unitWork = _autofacServiceProvider.GetService<IUnitWork>();
var unitWork = _autofacServiceProvider.GetService<IUnitWork<OpenAuthDBContext>>();
var account = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss");
try
{
@@ -57,7 +57,7 @@ namespace OpenAuth.Repository.Test
/// <summary>
/// 测试添加单个修改Z.EntityFramework.Plus条件修改
/// </summary>
private void AddAndUpdate(string account, IUnitWork unitWork)
private void AddAndUpdate(string account, IUnitWork<OpenAuthDBContext> unitWork)
{
var user = new User
{