z8018
2026-02-11 b8fb68b44c29e4667f6ea5746119413809a60a9e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using KH.WMS.Core.Database.Repositories;
 
namespace KH.WMS.Core.Database.UnitOfWorks
{
    /// <summary>
    /// 工作单元接口
    /// </summary>
    public interface IUnitOfWork : IDisposable
    {
        /// <summary>
        /// 开始事务
        /// </summary>
        Task BeginTransactionAsync(System.Data.IsolationLevel isolationLevel = System.Data.IsolationLevel.ReadCommitted);
 
        /// <summary>
        /// 提交事务
        /// </summary>
        Task CommitAsync();
 
        /// <summary>
        /// 回滚事务
        /// </summary>
        Task RollbackAsync();
 
        /// <summary>
        /// 获取数据库上下文
        /// </summary>
        IDbContext DbContext { get; }
 
        /// <summary>
        /// 获取仓储
        /// </summary>
        IRepository<T, TKey> GetRepository<T, TKey>() where T : class where TKey : struct;
 
        /// <summary>
        /// 执行 SQL 命令
        /// </summary>
        Task<int> ExecuteSqlAsync<TKey>(string sql, params object?[] parameters) where TKey : struct;
 
        /// <summary>
        /// 执行 SQL 命令(返回列表)
        /// </summary>
        Task<List<T>> ExecuteSqlAsync<T, TKey>(string sql, params object?[] parameters) where T : class where TKey : struct;
    }
}