wanshenmean
2024-09-13 319e8729b47c96e3a3717c5a40cd5df867d65ce5
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs
@@ -15,6 +15,9 @@
using WIDESEA_Core.DB;
using WIDESEA_Core.Const;
using WIDESEA_Core.AOP;
using AngleSharp.Dom;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using SharpCompress.Common;
namespace WIDESEA_Core.BaseRepository
{
@@ -33,7 +36,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();
@@ -586,7 +589,6 @@
        //    Expression<Func<T, T2, T3, bool>> whereLambda = null) where T : class, new(){throw new NotImplementedException();}
        //Task<PageModel<TEntity>> QueryPage(PaginationModel pagination){throw new NotImplementedException();}
        public Task<TEntity> QureyDataByIdAsync(object id)
        {
            return _db.Queryable<TEntity>().In(id).SingleAsync();
@@ -606,6 +608,16 @@
        {
            IInsertable<TEntity> insert = _db.Insertable(entity);
            return insert.ExecuteReturnIdentityAsync();
        }
        /// <summary>
        /// 导航插入数据(只支持2级)
        /// </summary>
        /// <param name="Entity"></param>
        /// <returns></returns>
        public async Task<bool> AddDataNavAsync(TEntity Entity)
        {
            return await _db.InsertNav(Entity).IncludesAllFirstLayer().ExecuteCommandAsync();
        }
        public Task<int> AddDataAsync(List<TEntity> listEntity)
@@ -679,6 +691,11 @@
        public Task<TEntity> QueryFirstAsync(Expression<Func<TEntity, bool>> whereExpression)
        {
            return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).FirstAsync();
        }
        public Task<TEntity> QueryFirstNavAsync(Expression<Func<TEntity, bool>> whereExpression)
        {
            return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).IncludesAllFirstLayer().FirstAsync();
        }
        public Task<TResult> QueryFirstAsync<TResult>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, TResult>> expression)
@@ -867,4 +884,4 @@
        //    Expression<Func<T, T2, T3, bool>> whereLambda = null) where T : class, new(){throw new NotImplementedException();}
        //Task<PageModel<TEntity>> QueryPage(PaginationModel pagination){throw new NotImplementedException();}
    }
}
}