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