using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.Core.DatabaseAccessor.Entity
{
///
/// 业务单元操作接口
///
public interface IUnitOfWork : IDisposable
{
///
/// 获取 工作单元的事务是否已提交
///
bool HasCommitted { get; }
///
/// 添加DbContext共享事务
///
void AddDbContext(DbContext dbContext);
///
/// 获取指定数据实体的上下文类型
///
/// 实体类型
/// 实体所属上下文实例
DbContext GetDbContext();
///
/// 对数据库连接开启事务
///
void BeginOrUseTransaction();
///
/// 对数据库连接开启事务
///
/// 异步取消标记
///
Task BeginOrUseTransactionAsync(CancellationToken cancellationToken = default);
///
/// 提交当前上下文的事务更改
///
void Commit();
///
/// 回滚所有事务
///
void Rollback();
}
}