From 64a2aa2301946f777659239247233e47ad1e3076 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 12 四月 2026 11:54:15 +0800
Subject: [PATCH] feat(事务管理): 添加异步事务处理方法

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs |   48 ++++++++++++++++++++++++++++--------------------
 1 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs
index 41c5bd7..8647ac6 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs
@@ -1,26 +1,11 @@
-锘縰sing SqlSugar;
+锘縰sing Microsoft.Data.SqlClient;
+using SqlSugar;
 using System.Data;
 using System.Linq.Expressions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Reflection;
-using WIDESEA_Core.Helper;
-using Microsoft.Data.SqlClient;
-using System.Drawing.Printing;
-using WIDESEA_Core.Tenants;
-using WIDESEA_Core.Seed;
-using WIDESEA_Core.DB;
-using WIDESEA_Core.Const;
-using WIDESEA_Core.AOP;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
+using WIDESEA_Core.DB.Models;
 using WIDESEA_Core.Enums;
 using WIDESEA_Core.Utilities;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using NetTaste;
-using WIDESEA_Core.DB.Models;
 
 namespace WIDESEA_Core.BaseRepository
 {
@@ -39,7 +24,7 @@
                 //var mta = typeof(TEntity).GetCustomAttribute<MultiTenantAttribute>();
                 //if (mta is { TenantType: TenantTypeEnum.Db })
                 //{
-                //    //鑾峰彇绉熸埛淇℃伅 绉熸埛淇℃伅鍙互鎻愬墠缂撳瓨涓嬫潵 
+                //    //鑾峰彇绉熸埛淇℃伅 绉熸埛淇℃伅鍙互鎻愬墠缂撳瓨涓嬫潵
                 //    if (App.User is { TenantId: > 0 })
                 //    {
                 //        dynamic tenant = db.Queryable(MainDb.TenantTableName, "x").Where(MainDb.TenantId, "=", App.User.TenantId).First();
@@ -72,6 +57,7 @@
                 return db;
             }
         }
+
         /// <summary>
         /// 鍒涘缓鏁版嵁搴撹繛鎺ュ璞�
         /// </summary>
@@ -963,11 +949,33 @@
                     }
                     if (list.Count > 0)
                         _db.InsertableByObject(list).AS(type.Name + "_Hty").ExecuteCommand();
-
                 }
             }
             return DeleteData(entities);
         }
+
+        public async Task<int> GetTaskNo()
+        {
+            string sql = "select next value for dbo.GetTaskNum";
+            return await Db.Ado.SqlQuerySingleAsync<int>(sql);
+        }
+
+        public virtual async Task<List<TEntity>> QueryDataNavAsync(Expression<Func<TEntity, bool>> whereExpression)
+        {
+            return await _db.Queryable<TEntity>()
+                .Where(whereExpression)
+                .IncludesAllFirstLayer()
+                .ToListAsync();
+        }
+
+        public virtual async Task<TEntity> QueryDataNavFirstAsync(Expression<Func<TEntity, bool>> whereExpression)
+        {
+            return await _db.Queryable<TEntity>()
+                .Where(whereExpression)
+                .IncludesAllFirstLayer()
+                .FirstAsync();
+        }
+
         //List<TResult> QueryMuch<T, T2, T3, TResult>(
         //    Expression<Func<T, T2, T3, object[]>> joinExpression,
         //    Expression<Func<T, T2, T3, TResult>> selectExpression,

--
Gitblit v1.9.3