From 8d341db9d2d5699d527c88c935f0c4ce255a57a4 Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期二, 10 十二月 2024 16:38:12 +0800
Subject: [PATCH] 代码提交

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs |   65 +++++++++++++++++---------------
 1 files changed, 35 insertions(+), 30 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs"
index ed69c09..dc269d7 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs"
@@ -36,38 +36,38 @@
                 ISqlSugarClient db = _dbBase;
 
                 //澶氱鎴�
-                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();
-                        if (tenant != null)
-                        {
-                            var iTenant = db.AsTenant();
-                            if (!iTenant.IsAnyConnection(tenant.TenantId))
-                            {
-                                string conStr = tenant.ConnectionString;
-                                ConnectionConfig connectionConfig = new ConnectionConfig()
-                                {
-                                    ConfigId = tenant.TenantId,
-                                    ConnectionString = conStr.DecryptDES(AppSecret.DB),
-                                    DbType = (SqlSugar.DbType)tenant.DbType,
-                                    IsAutoCloseConnection = true,
-                                    AopEvents = new AopEvents()
-                                    {
-                                        DataExecuting = SqlSugarAop.DataExecuting,
+                //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();
+                //        if (tenant != null)
+                //        {
+                //            var iTenant = db.AsTenant();
+                //            if (!iTenant.IsAnyConnection(tenant.TenantId))
+                //            {
+                //                string conStr = tenant.ConnectionString;
+                //                ConnectionConfig connectionConfig = new ConnectionConfig()
+                //                {
+                //                    ConfigId = tenant.TenantId,
+                //                    ConnectionString = conStr.DecryptDES(AppSecret.DB),
+                //                    DbType = (SqlSugar.DbType)tenant.DbType,
+                //                    IsAutoCloseConnection = true,
+                //                    AopEvents = new AopEvents()
+                //                    {
+                //                        DataExecuting = SqlSugarAop.DataExecuting,
 
-                                    }
-                                };
-                                iTenant.AddConnection(connectionConfig);
-                            }
+                //                    }
+                //                };
+                //                iTenant.AddConnection(connectionConfig);
+                //            }
 
-                            return iTenant.GetConnection(tenant.TenantId);
-                        }
-                    }
-                }
+                //            return iTenant.GetConnection(tenant.TenantId);
+                //        }
+                //    }
+                //}
 
                 return db;
             }
@@ -124,6 +124,11 @@
             return insert.ExecuteReturnIdentity();
         }
 
+        public virtual bool AddData<TChild>(TEntity entity, Expression<Func<TEntity, List<TChild>>> expression) where TChild : class, new()
+        {
+            return _db.InsertNav(entity).Include(expression).ExecuteCommand();
+        }
+
         /// <summary>
         /// 娣诲姞澶氭潯鏁版嵁
         /// </summary>

--
Gitblit v1.9.3