|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
using Entity.Common;
|
|
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace Repository;
|
|
|
|
@ -1004,105 +1004,97 @@ public abstract class BaseRepository<T> where T : class, new()
|
|
|
|
|
{
|
|
|
|
|
return await DbBaseClient.Queryable<T>().Where(predicate).WithNoLockOrNot(blUseNoLock).SumAsync(field);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据条件查询表单数据(分页)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="page"> 页数</param>
|
|
|
|
|
/// <param name="pageSize">每页几条数据</param>
|
|
|
|
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public IPage<T> QueryIPageByCause(QueryPageModel page, Expression<Func<T, bool>> predicate)
|
|
|
|
|
{
|
|
|
|
|
if (null == predicate) {
|
|
|
|
|
return this.QueryIPage(page);
|
|
|
|
|
}
|
|
|
|
|
int totalCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<T> pageList = DbBaseClient
|
|
|
|
|
.Queryable<T>()
|
|
|
|
|
.Where(predicate)
|
|
|
|
|
.WithNoLockOrNot(false)
|
|
|
|
|
.ToPageList(page.Page, page.PageSize, ref totalCount);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new IPage<T>(totalCount, page, pageList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据条件查询表单数据(分页) 异步
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="page"></param>
|
|
|
|
|
/// <param name="predicate"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<IPage<T>> QueryIPageByCauseAsync(QueryPageModel page, Expression<Func<T, bool>> predicate)
|
|
|
|
|
{
|
|
|
|
|
if (null == predicate)
|
|
|
|
|
{
|
|
|
|
|
return await this.QueryIPageAsync(page);
|
|
|
|
|
}
|
|
|
|
|
RefAsync<int> totalCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<T> pageList = await DbBaseClient
|
|
|
|
|
.Queryable<T>()
|
|
|
|
|
.Where(predicate)
|
|
|
|
|
.WithNoLockOrNot(false)
|
|
|
|
|
.ToPageListAsync(page.Page, page.PageSize, totalCount);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new IPage<T>(totalCount, page, pageList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询表单所有数据(分页)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="page"> 页数</param>
|
|
|
|
|
/// <param name="pageSize">每页几条数据</param>
|
|
|
|
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public IPage<T> QueryIPage(QueryPageModel page)
|
|
|
|
|
{
|
|
|
|
|
int totalCount = 0;
|
|
|
|
|
//page.Page = page.Page == 0 ? 1 : page.Page;//默认第一页 10条数据
|
|
|
|
|
//page.PageSize = page.PageSize == 0 ? 10 : page.PageSize;
|
|
|
|
|
|
|
|
|
|
List<T> pageList = DbBaseClient
|
|
|
|
|
.Queryable<T>()
|
|
|
|
|
.WithNoLockOrNot(false)
|
|
|
|
|
.ToPageList(page.Page, page.PageSize, ref totalCount);
|
|
|
|
|
|
|
|
|
|
return new IPage<T>(totalCount, page, pageList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询表单所有数据(分页) 异步
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="page"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<IPage<T>> QueryIPageAsync(QueryPageModel page)
|
|
|
|
|
{
|
|
|
|
|
RefAsync<int> totalCount = 0;
|
|
|
|
|
|
|
|
|
|
List<T> pageList = await DbBaseClient
|
|
|
|
|
.Queryable<T>()
|
|
|
|
|
.WithNoLockOrNot(false)
|
|
|
|
|
.ToPageListAsync(page.Page, page.PageSize, totalCount);
|
|
|
|
|
|
|
|
|
|
return new IPage<T>(totalCount, page, pageList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据条件查询分页数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="predicate"></param>
|
|
|
|
|
/// <param name="orderBy"></param>
|
|
|
|
|
/// <param name="pageIndex">当前页面索引</param>
|
|
|
|
|
/// <param name="pageSize">分布大小</param>
|
|
|
|
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public IPageList<T> QueryPage(Expression<Func<T, bool>> predicate, string orderBy = "", int pageIndex = 1,
|
|
|
|
|
int pageSize = 20, bool blUseNoLock = false)
|
|
|
|
|
{
|
|
|
|
|
var totalCount = 0;
|
|
|
|
|
var page = DbBaseClient
|
|
|
|
|
.Queryable<T>()
|
|
|
|
|
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
|
|
|
|
.WhereIF(predicate != null, predicate)
|
|
|
|
|
.WithNoLockOrNot(blUseNoLock)
|
|
|
|
|
.ToPageList(pageIndex, pageSize, ref totalCount);
|
|
|
|
|
|
|
|
|
|
var list = new PageList<T>(page, pageIndex, pageSize, totalCount);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据条件查询分页数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="predicate"></param>
|
|
|
|
|
/// <param name="orderBy"></param>
|
|
|
|
|
/// <param name="pageIndex">当前页面索引</param>
|
|
|
|
|
/// <param name="pageSize">分布大小</param>
|
|
|
|
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<IPageList<T>> QueryPageAsync(Expression<Func<T, bool>> predicate, string orderBy = "",
|
|
|
|
|
int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false)
|
|
|
|
|
{
|
|
|
|
|
RefAsync<int> totalCount = 0;
|
|
|
|
|
var page = await DbBaseClient
|
|
|
|
|
.Queryable<T>()
|
|
|
|
|
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
|
|
|
|
.WhereIF(predicate != null, predicate)
|
|
|
|
|
.WithNoLockOrNot(blUseNoLock)
|
|
|
|
|
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
|
|
|
|
var list = new PageList<T>(page, pageIndex, pageSize, totalCount);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据条件查询分页数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="predicate">判断集合</param>
|
|
|
|
|
/// <param name="orderByType">排序方式</param>
|
|
|
|
|
/// <param name="pageIndex">当前页面索引</param>
|
|
|
|
|
/// <param name="pageSize">分布大小</param>
|
|
|
|
|
/// <param name="orderByExpression"></param>
|
|
|
|
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public IPageList<T> QueryPage(Expression<Func<T, bool>> predicate,
|
|
|
|
|
Expression<Func<T, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
|
|
|
|
int pageSize = 20, bool blUseNoLock = false)
|
|
|
|
|
{
|
|
|
|
|
var totalCount = 0;
|
|
|
|
|
var page = DbBaseClient
|
|
|
|
|
.Queryable<T>()
|
|
|
|
|
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
|
|
|
|
.WhereIF(predicate != null, predicate)
|
|
|
|
|
.WithNoLockOrNot(blUseNoLock)
|
|
|
|
|
.ToPageList(pageIndex, pageSize, ref totalCount);
|
|
|
|
|
|
|
|
|
|
var list = new PageList<T>(page, pageIndex, pageSize, totalCount);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据条件查询分页数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="predicate">判断集合</param>
|
|
|
|
|
/// <param name="orderByType">排序方式</param>
|
|
|
|
|
/// <param name="pageIndex">当前页面索引</param>
|
|
|
|
|
/// <param name="pageSize">分布大小</param>
|
|
|
|
|
/// <param name="orderByExpression"></param>
|
|
|
|
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<IPageList<T>> QueryPageAsync(Expression<Func<T, bool>> predicate,
|
|
|
|
|
Expression<Func<T, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
|
|
|
|
int pageSize = 20, bool blUseNoLock = false)
|
|
|
|
|
{
|
|
|
|
|
RefAsync<int> totalCount = 0;
|
|
|
|
|
var page = await DbBaseClient
|
|
|
|
|
.Queryable<T>()
|
|
|
|
|
.WhereIF(predicate != null, predicate)
|
|
|
|
|
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
|
|
|
|
.WithNoLockOrNot(blUseNoLock)
|
|
|
|
|
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
|
|
|
|
|
|
|
|
|
var list = new PageList<T>(page, pageIndex, pageSize, totalCount);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询-2表查询
|
|
|
|
|