From c9982eb3dd76696b8a3851cc6411a71c402d042f Mon Sep 17 00:00:00 2001 From: wanshenmean <cathay_xy@163.com> Date: 星期三, 06 十一月 2024 20:04:41 +0800 Subject: [PATCH] 11.06 --- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs | 33 ++++++++++++++++++++++++++------- 1 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs index 539c96b..607821b 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs +++ b/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(); @@ -392,7 +395,7 @@ /// <returns></returns> public virtual List<TEntity> QueryData(Expression<Func<TEntity, bool>> whereExpression, int top, string orderByFields) { - return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Take(top).ToList(); + return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Take(top).IncludesAllFirstLayer().ToList(); } /// <summary> @@ -404,7 +407,7 @@ /// <returns></returns> public virtual List<TEntity> QueryData(string where, int top, string orderByFields) { - return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).Take(top).ToList(); + return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).Take(top).IncludesAllFirstLayer().ToList(); } /// <summary> @@ -432,7 +435,7 @@ public virtual List<TEntity> QueryData(string where, int pageIndex, int pageSize, string orderByFields) { return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) - .WhereIF(!string.IsNullOrEmpty(where), where).ToPageList(pageIndex, pageSize); + .WhereIF(!string.IsNullOrEmpty(where), where).IncludesAllFirstLayer().ToPageList(pageIndex, pageSize); } /// <summary> @@ -449,6 +452,7 @@ var list = _db.Queryable<TEntity>() .OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) .WhereIF(whereExpression != null, whereExpression) + .IncludesAllFirstLayer() .ToPageList(pageIndex, pageSize, ref totalCount); return new PageGridData<TEntity> { Rows = list, Total = totalCount }; @@ -478,6 +482,7 @@ List<TEntity> list = _db.Queryable<TEntity>() .OrderBy(orderByModels) .WhereIF(whereExpression != null, whereExpression) + .IncludesAllFirstLayer() .ToPageList(pageIndex, pageSize, ref totalCount); return new PageGridData<TEntity>(totalCount, list); @@ -505,7 +510,7 @@ } int totalCount = 0; List<TEntity> list = _db.Queryable<TEntity>() - .WhereIF(!string.IsNullOrEmpty(where), where).OrderBy(orderByModels).ToPageList(pageIndex, pageSize, ref totalCount); + .WhereIF(!string.IsNullOrEmpty(where), where).OrderBy(orderByModels).IncludesAllFirstLayer().ToPageList(pageIndex, pageSize, ref totalCount); return new PageGridData<TEntity>(totalCount, list); } @@ -586,7 +591,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 +610,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 +693,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 +886,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();} } -} +} \ No newline at end of file -- Gitblit v1.9.3