Browse Source

Add GetDbConnectionAsync and GetDbTransactionAsync methods to EF Core base repository class

pull/16149/head
Halil İbrahim Kalkan 3 years ago
parent
commit
f815aba4b8
  1. 12
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs

12
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs

@ -4,11 +4,13 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Storage;
using Volo.Abp.Domain.Entities;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.DependencyInjection;
@ -73,6 +75,16 @@ public class EfCoreRepository<TDbContext, TEntity> : RepositoryBase<TEntity>, IE
{
return (await GetDbContextAsync()).Set<TEntity>();
}
protected async Task<IDbConnection> GetDbConnectionAsync()
{
return (await GetDbContextAsync()).Database.GetDbConnection();
}
protected async Task<IDbTransaction> GetDbTransactionAsync()
{
return (await GetDbContextAsync()).Database.CurrentTransaction?.GetDbTransaction();
}
protected virtual AbpEntityOptions<TEntity> AbpEntityOptions => _entityOptionsLazy.Value;

Loading…
Cancel
Save