diff --git a/ConsoleStarter/ConsoleStarter.csproj b/ConsoleStarter/ConsoleStarter.csproj
index 57b5dae..5849726 100644
--- a/ConsoleStarter/ConsoleStarter.csproj
+++ b/ConsoleStarter/ConsoleStarter.csproj
@@ -16,7 +16,7 @@
-
+
diff --git a/Entity/Common/IPageList.cs b/Entity/Common/IPageList.cs
deleted file mode 100644
index 438c220..0000000
--- a/Entity/Common/IPageList.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace Entity.Common;
-
-public interface IPageList : IList
-{
- int PageIndex { get; }
- int PageSize { get; }
- int TotalCount { get; }
- int TotalPages { get; }
- bool HasPreviousPage { get; }
- bool HasNextPage { get; }
-}
\ No newline at end of file
diff --git a/Entity/Common/PageList.cs b/Entity/Common/PageList.cs
deleted file mode 100644
index 89eb1ba..0000000
--- a/Entity/Common/PageList.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-namespace Entity.Common;
-
-///
-/// 分页组件实体类
-///
-/// 泛型实体
-[Serializable]
-public class PageList : List, IPageList
-{
- ///
- /// 构造函数
- ///
- /// 数据源
- /// 分页索引
- /// 分页大小
- public PageList(IQueryable source, int pageIndex, int pageSize)
- {
- var total = source.Count();
- TotalCount = total;
- TotalPages = total / pageSize;
-
- if (total % pageSize > 0)
- TotalPages++;
-
- PageSize = pageSize;
- PageIndex = pageIndex;
-
- AddRange(source.Skip(pageIndex * pageSize).Take(pageSize).ToList());
- }
-
- ///
- /// 构造函数
- ///
- /// 数据源
- /// 分页索引
- /// 分页大小
- public PageList(IList source, int pageIndex, int pageSize)
- {
- TotalCount = source.Count();
- TotalPages = TotalCount / pageSize;
-
- if (TotalCount % pageSize > 0)
- TotalPages++;
-
- PageSize = pageSize;
- PageIndex = pageIndex;
- AddRange(source.Skip(pageIndex * pageSize).Take(pageSize).ToList());
- }
-
- ///
- /// 构造函数
- ///
- /// 数据源
- /// 分页索引
- /// 分页大小
- /// 总记录数
- public PageList(IEnumerable source, int pageIndex, int pageSize, int totalCount)
- {
- TotalCount = totalCount;
- TotalPages = TotalCount / pageSize;
-
- if (TotalCount % pageSize > 0)
- TotalPages++;
-
- PageSize = pageSize;
- PageIndex = pageIndex;
- AddRange(source);
- }
-
- ///
- /// 分页索引
- ///
- public int PageIndex { get; }
-
- ///
- /// 分页大小
- ///
- public int PageSize { get; private set; }
-
- ///
- /// 总记录数
- ///
- public int TotalCount { get; }
-
- ///
- /// 总页数
- ///
- public int TotalPages { get; }
-
- ///
- /// 是否有上一页
- ///
- public bool HasPreviousPage => PageIndex > 0;
-
- ///
- /// 是否有下一页
- ///
- public bool HasNextPage => PageIndex + 1 < TotalPages;
-}
\ No newline at end of file
diff --git a/Entity/Entity.csproj b/Entity/Entity.csproj
index 9352d52..f1a99d1 100644
--- a/Entity/Entity.csproj
+++ b/Entity/Entity.csproj
@@ -6,8 +6,16 @@
enable
+
+ bin\Debug\Entity.xml
+
+
+
+ bin\Release\Entity.xml
+
+
-
+
diff --git a/HybirdFrameworkCore/Entity/IPage.cs b/HybirdFrameworkCore/Entity/IPage.cs
new file mode 100644
index 0000000..b9a8d4a
--- /dev/null
+++ b/HybirdFrameworkCore/Entity/IPage.cs
@@ -0,0 +1,20 @@
+namespace HybirdFrameworkCore.Entity;
+
+public class IPage
+{
+ public int Total;
+
+ public int PageNum;
+
+ public int PageSize;
+
+ public List? Rows;
+
+ public IPage(int total, QueryPageModel page, List? rows)
+ {
+ Total = total;
+ PageNum = page.Page;
+ PageSize = page.PageSize;
+ Rows = rows;
+ }
+}
\ No newline at end of file
diff --git a/HybirdFrameworkCore/Entity/PageResult.cs b/HybirdFrameworkCore/Entity/PageResult.cs
new file mode 100644
index 0000000..80d49fc
--- /dev/null
+++ b/HybirdFrameworkCore/Entity/PageResult.cs
@@ -0,0 +1,58 @@
+using System.Diagnostics;
+using AutoMapper;
+
+namespace HybirdFrameworkCore.Entity
+{
+ public class PageResult
+ {
+ ///
+ /// 当前页标
+ ///
+ public int PageNum { get; set; }
+
+ ///
+ /// 每页大小
+ ///
+ public int PageSize { set; get; }
+
+ ///
+ /// 返回数据
+ ///
+ public List? Rows { get; set; }
+
+ ///
+ /// 当前页标
+ ///
+ public long ToTal { get; set; }
+
+ public PageResult()
+ {
+ PageSize = 0;
+ PageNum = 0;
+ ToTal = 0;
+ Rows = new List();
+ }
+
+
+ public static PageResult ConvertPage(IPage page) where TS : class, new()
+ {
+ if (page.Total <= 0 || page.Rows == null)
+ {
+ return new PageResult();
+ }
+
+ MapperConfiguration configuration = new MapperConfiguration(cfg => cfg.CreateMap());
+
+ Debug.Assert(page.Rows != null, "iPage.Rows != null");
+ List listDest = configuration.CreateMapper().Map, List>(page.Rows);
+
+ return new PageResult()
+ {
+ PageSize = page.PageSize,
+ PageNum = page.PageNum,
+ ToTal = page.Total,
+ Rows = listDest,
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/HybirdFrameworkCore/HybirdFrameworkCore.csproj b/HybirdFrameworkCore/HybirdFrameworkCore.csproj
index ae3db33..b990fc1 100644
--- a/HybirdFrameworkCore/HybirdFrameworkCore.csproj
+++ b/HybirdFrameworkCore/HybirdFrameworkCore.csproj
@@ -6,8 +6,17 @@
enable
+
+ bin\Debug\HybirdFrameworkCore.xml
+
+
+
+ bin\Release\HybirdFrameworkCore.xml
+
+
+
diff --git a/Repository/BaseRepository.cs b/Repository/BaseRepository.cs
index c1e94fc..dfa0cda 100644
--- a/Repository/BaseRepository.cs
+++ b/Repository/BaseRepository.cs
@@ -1,5 +1,5 @@
using System.Linq.Expressions;
-using Entity.Common;
+using HybirdFrameworkCore.Entity;
using SqlSugar;
namespace Repository;
@@ -88,6 +88,98 @@ public abstract class BaseRepository where T : class, new()
.WithNoLockOrNot(blUseNoLock)
.ToList();
}
+
+
+ ///
+ /// 根据条件查询表单数据(分页)
+ ///
+ /// 页数
+ /// 每页几条数据
+ /// 是否使用WITH(NOLOCK)
+ ///
+ public IPage QueryIPageByCause(QueryPageModel page, Expression> predicate)
+ {
+ if (null == predicate) {
+ return this.QueryIPage(page);
+ }
+ int totalCount = 0;
+
+
+ List pageList = DbBaseClient
+ .Queryable()
+ .Where(predicate)
+ .WithNoLockOrNot(false)
+ .ToPageList(page.Page, page.PageSize, ref totalCount);
+
+
+
+ return new IPage(totalCount, page, pageList);
+ }
+
+ ///
+ /// 根据条件查询表单数据(分页) 异步
+ ///
+ ///
+ ///
+ ///
+ public async Task> QueryIPageByCauseAsync(QueryPageModel page, Expression> predicate)
+ {
+ if (null == predicate)
+ {
+ return await this.QueryIPageAsync(page);
+ }
+ RefAsync totalCount = 0;
+
+
+ List pageList = await DbBaseClient
+ .Queryable()
+ .Where(predicate)
+ .WithNoLockOrNot(false)
+ .ToPageListAsync(page.Page, page.PageSize, totalCount);
+
+
+
+ return new IPage(totalCount, page, pageList);
+ }
+
+
+ ///
+ /// 查询表单所有数据(分页)
+ ///
+ /// 页数
+ /// 每页几条数据
+ /// 是否使用WITH(NOLOCK)
+ ///
+ public IPage QueryIPage(QueryPageModel page)
+ {
+ int totalCount = 0;
+ //page.Page = page.Page == 0 ? 1 : page.Page;//默认第一页 10条数据
+ //page.PageSize = page.PageSize == 0 ? 10 : page.PageSize;
+
+ List pageList = DbBaseClient
+ .Queryable()
+ .WithNoLockOrNot(false)
+ .ToPageList(page.Page, page.PageSize, ref totalCount);
+
+ return new IPage(totalCount, page, pageList);
+ }
+
+ ///
+ /// 查询表单所有数据(分页) 异步
+ ///
+ ///
+ ///
+ public async Task> QueryIPageAsync(QueryPageModel page)
+ {
+ RefAsync totalCount = 0;
+
+ List pageList = await DbBaseClient
+ .Queryable()
+ .WithNoLockOrNot(false)
+ .ToPageListAsync(page.Page, page.PageSize, totalCount);
+
+ return new IPage(totalCount, page, pageList);
+ }
///
/// 根据主值列表查询单条数据
@@ -1005,104 +1097,7 @@ public abstract class BaseRepository where T : class, new()
return await DbBaseClient.Queryable().Where(predicate).WithNoLockOrNot(blUseNoLock).SumAsync(field);
}
- ///
- /// 根据条件查询分页数据
- ///
- ///
- ///
- /// 当前页面索引
- /// 分布大小
- /// 是否使用WITH(NOLOCK)
- ///
- public IPageList QueryPage(Expression> predicate, string orderBy = "", int pageIndex = 1,
- int pageSize = 20, bool blUseNoLock = false)
- {
- var totalCount = 0;
- var page = DbBaseClient
- .Queryable()
- .OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
- .WhereIF(predicate != null, predicate)
- .WithNoLockOrNot(blUseNoLock)
- .ToPageList(pageIndex, pageSize, ref totalCount);
-
- var list = new PageList(page, pageIndex, pageSize, totalCount);
- return list;
- }
-
- ///
- /// 根据条件查询分页数据
- ///
- ///
- ///
- /// 当前页面索引
- /// 分布大小
- /// 是否使用WITH(NOLOCK)
- ///
- public async Task> QueryPageAsync(Expression> predicate, string orderBy = "",
- int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false)
- {
- RefAsync totalCount = 0;
- var page = await DbBaseClient
- .Queryable()
- .OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
- .WhereIF(predicate != null, predicate)
- .WithNoLockOrNot(blUseNoLock)
- .ToPageListAsync(pageIndex, pageSize, totalCount);
- var list = new PageList(page, pageIndex, pageSize, totalCount);
- return list;
- }
-
- ///
- /// 根据条件查询分页数据
- ///
- /// 判断集合
- /// 排序方式
- /// 当前页面索引
- /// 分布大小
- ///
- /// 是否使用WITH(NOLOCK)
- ///
- public IPageList QueryPage(Expression> predicate,
- Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1,
- int pageSize = 20, bool blUseNoLock = false)
- {
- var totalCount = 0;
- var page = DbBaseClient
- .Queryable()
- .OrderByIF(orderByExpression != null, orderByExpression, orderByType)
- .WhereIF(predicate != null, predicate)
- .WithNoLockOrNot(blUseNoLock)
- .ToPageList(pageIndex, pageSize, ref totalCount);
-
- var list = new PageList(page, pageIndex, pageSize, totalCount);
- return list;
- }
-
- ///
- /// 根据条件查询分页数据
- ///
- /// 判断集合
- /// 排序方式
- /// 当前页面索引
- /// 分布大小
- ///
- /// 是否使用WITH(NOLOCK)
- ///
- public async Task> QueryPageAsync(Expression> predicate,
- Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1,
- int pageSize = 20, bool blUseNoLock = false)
- {
- RefAsync totalCount = 0;
- var page = await DbBaseClient
- .Queryable()
- .WhereIF(predicate != null, predicate)
- .OrderByIF(orderByExpression != null, orderByExpression, orderByType)
- .WithNoLockOrNot(blUseNoLock)
- .ToPageListAsync(pageIndex, pageSize, totalCount);
-
- var list = new PageList(page, pageIndex, pageSize, totalCount);
- return list;
- }
+
///
/// 查询-2表查询
diff --git a/Repository/Repository.csproj b/Repository/Repository.csproj
index 9c691e6..7e55f6e 100644
--- a/Repository/Repository.csproj
+++ b/Repository/Repository.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/Service/BaseServices.cs b/Service/BaseServices.cs
index afaaeb7..53a4627 100644
--- a/Service/BaseServices.cs
+++ b/Service/BaseServices.cs
@@ -1,5 +1,4 @@
using System.Linq.Expressions;
-using Entity.Common;
using Repository;
using SqlSugar;
@@ -876,70 +875,7 @@ public class BaseServices where T : class, new()
return await BaseDal.GetSumAsync(predicate, field, blUseNoLock);
}
- ///
- /// 根据条件查询分页数据
- ///
- ///
- ///
- /// 当前页面索引
- /// 分布大小
- /// 是否使用WITH(NOLOCK)
- ///
- public IPageList QueryPage(Expression> predicate, string orderBy = "", int pageIndex = 1,
- int pageSize = 20, bool blUseNoLock = false)
- {
- return BaseDal.QueryPage(predicate, orderBy, pageIndex, pageSize, blUseNoLock);
- }
-
- ///
- /// 根据条件查询分页数据
- ///
- ///
- ///
- /// 当前页面索引
- /// 分布大小
- /// 是否使用WITH(NOLOCK)
- ///
- public async Task> QueryPageAsync(Expression> predicate, string orderBy = "",
- int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false)
- {
- return await BaseDal.QueryPageAsync(predicate, orderBy, pageIndex, pageSize, blUseNoLock);
- }
- ///
- /// 根据条件查询分页数据
- ///
- /// 判断集合
- /// 排序方式
- /// 当前页面索引
- /// 分布大小
- ///
- /// 是否使用WITH(NOLOCK)
- ///
- public IPageList QueryPage(Expression> predicate,
- Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1,
- int pageSize = 20, bool blUseNoLock = false)
- {
- return BaseDal.QueryPage(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock);
- }
-
- ///
- /// 根据条件查询分页数据
- ///
- /// 判断集合
- /// 排序方式
- /// 当前页面索引
- /// 分布大小
- ///
- /// 是否使用WITH(NOLOCK)
- ///
- public async Task> QueryPageAsync(Expression> predicate,
- Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1,
- int pageSize = 20, bool blUseNoLock = false)
- {
- return await BaseDal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize,
- blUseNoLock);
- }
///
/// 查询-多表查询
diff --git a/Service/Service.csproj b/Service/Service.csproj
index 1ee60b6..433e1ae 100644
--- a/Service/Service.csproj
+++ b/Service/Service.csproj
@@ -14,7 +14,7 @@
-
+
diff --git a/WebStarter/Program.cs b/WebStarter/Program.cs
index 4280c00..7f85404 100644
--- a/WebStarter/Program.cs
+++ b/WebStarter/Program.cs
@@ -45,12 +45,13 @@ builder.Services.AddCors(options =>
builder.Services.AddSwaggerGen(c =>
{
- string? basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location); //获取应用程序所在目录
- if (basePath != null)
- {
- string xmlPath = Path.Combine(basePath, "WebStarter.xml");
- c.IncludeXmlComments(xmlPath);
- }
+ var basePath = Path.GetDirectoryName(AppContext.BaseDirectory);
+ //c.IncludeXmlComments(Path.Combine(basePath, Assembly.GetExecutingAssembly().GetName().Name+".xml"), true);
+ c.IncludeXmlComments(Path.Combine(basePath, "WebStarter.xml"), true);
+ c.IncludeXmlComments(Path.Combine(basePath, "Entity.xml"), true);
+ c.IncludeXmlComments(Path.Combine(basePath, "HybirdFrameworkCore.xml"), true);
+
+
});
builder.Services.AddControllers().AddJsonOptions(configure =>
diff --git a/WebStarter/WebStarter.csproj b/WebStarter/WebStarter.csproj
index d876cd7..df95a28 100644
--- a/WebStarter/WebStarter.csproj
+++ b/WebStarter/WebStarter.csproj
@@ -6,6 +6,14 @@
enable
+
+ bin\Debug\WebStarter.xml
+
+
+
+ bin\Release\WebStarter.xml
+
+
diff --git a/WpfStarter/WpfStarter.csproj b/WpfStarter/WpfStarter.csproj
index bb66c09..acf2725 100644
--- a/WpfStarter/WpfStarter.csproj
+++ b/WpfStarter/WpfStarter.csproj
@@ -12,7 +12,7 @@
-
+