Skip to content

Commit 4affb11

Browse files
committed
feature:
处理代码
1 parent 2170733 commit 4affb11

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/framework/Luck.EntityFrameworkCore/DbContexts/LuckDbContextBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Luck.EntityFrameworkCore.DbContexts
88
/// <summary>
99
/// 类类上下文
1010
/// </summary>
11-
public class LuckDbContextBase(DbContextOptions options, IServiceProvider serviceProvider)
11+
public abstract class LuckDbContextBase(DbContextOptions options, IServiceProvider serviceProvider)
1212
: DbContext(options),ILuckDbContext
1313
{
1414
protected IServiceProvider ServiceProvider { get; set; } =

src/framework/Luck.EntityFrameworkCore/UnitOfWorks/UnitOfWork.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ namespace Luck.EntityFrameworkCore.UnitOfWorks
99
public class UnitOfWork : IUnitOfWork
1010
{
1111
//private readonly IDbContextFactory<ILuckDbContext> _dbContextFactory;
12-
protected LuckDbContextBase DbContext { get; }
12+
protected LuckDbContextBase DbContext => _luckDbContextBase;
1313

14+
private readonly LuckDbContextBase _luckDbContextBase;
15+
1416
private readonly ILogger<UnitOfWork> _logger;
1517

16-
public UnitOfWork(ILogger<UnitOfWork> logger, ILuckDbContext dbContext)
18+
public UnitOfWork(ILogger<UnitOfWork> logger, LuckDbContextBase luckDbContextBase)
1719
{
18-
DbContext = dbContext as LuckDbContextBase ?? throw new ArgumentNullException(nameof(ILuckDbContext));
20+
_luckDbContextBase = luckDbContextBase ?? throw new ArgumentNullException(nameof(ILuckDbContext));
1921
_logger = logger ?? throw new ArgumentNullException(nameof(ILogger));
2022
}
2123

@@ -40,7 +42,7 @@ public async Task<int> CommitAsync(CancellationToken cancellationToken = default
4042

4143
public ILuckDbContext GetLuckDbContext()
4244
{
43-
return DbContext;
45+
return _luckDbContextBase;
4446
}
4547
}
4648
}

0 commit comments

Comments
 (0)