From c937290366ce212c32dfcde05a3c67c9ff7d09c7 Mon Sep 17 00:00:00 2001 From: rszn <645583145@qq.com> Date: Wed, 5 Jun 2024 10:04:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=88=86=E9=A1=B5=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HybirdFrameworkCore/Entity/IPage.cs | 2 +- HybirdFrameworkCore/Entity/QueryPageModel.cs | 4 ++-- Repository/BaseRepository.cs | 20 +++++++++++++------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/HybirdFrameworkCore/Entity/IPage.cs b/HybirdFrameworkCore/Entity/IPage.cs index b9a8d4a..69bcb57 100644 --- a/HybirdFrameworkCore/Entity/IPage.cs +++ b/HybirdFrameworkCore/Entity/IPage.cs @@ -13,7 +13,7 @@ public class IPage public IPage(int total, QueryPageModel page, List? rows) { Total = total; - PageNum = page.Page; + PageNum = page.PageNum; PageSize = page.PageSize; Rows = rows; } diff --git a/HybirdFrameworkCore/Entity/QueryPageModel.cs b/HybirdFrameworkCore/Entity/QueryPageModel.cs index b8bfd4a..48cc3b6 100644 --- a/HybirdFrameworkCore/Entity/QueryPageModel.cs +++ b/HybirdFrameworkCore/Entity/QueryPageModel.cs @@ -5,9 +5,9 @@ public class QueryPageModel /// ///页码 /// - public int Page { get; set; } = 1; + public int PageNum { get; set; } = 1; /// /// 页数 /// public int PageSize { get; set; } = 10; -} \ No newline at end of file +} diff --git a/Repository/BaseRepository.cs b/Repository/BaseRepository.cs index 770092e..97f2c93 100644 --- a/Repository/BaseRepository.cs +++ b/Repository/BaseRepository.cs @@ -29,6 +29,12 @@ public abstract class BaseRepository where T : class, new() .InSingle(pkValue); } + public ISugarQueryable Queryable(bool blUseNoLock = false) + { + return DbBaseClient + .Queryable().WithNoLockOrNot(blUseNoLock); + } + /// /// 根据主值查询单条数据 /// @@ -109,7 +115,7 @@ public abstract class BaseRepository where T : class, new() .Queryable() .Where(predicate) .WithNoLockOrNot(false) - .ToPageList(page.Page, page.PageSize, ref totalCount); + .ToPageList(page.PageNum, page.PageSize, ref totalCount); @@ -135,7 +141,7 @@ public abstract class BaseRepository where T : class, new() .Queryable() .Where(predicate) .WithNoLockOrNot(false) - .ToPageListAsync(page.Page, page.PageSize, totalCount); + .ToPageListAsync(page.PageNum, page.PageSize, totalCount); @@ -159,7 +165,7 @@ public abstract class BaseRepository where T : class, new() List pageList = DbBaseClient .Queryable() .WithNoLockOrNot(false) - .ToPageList(page.Page, page.PageSize, ref totalCount); + .ToPageList(page.PageNum, page.PageSize, ref totalCount); return new IPage(totalCount, page, pageList); } @@ -176,7 +182,7 @@ public abstract class BaseRepository where T : class, new() List pageList = await DbBaseClient .Queryable() .WithNoLockOrNot(false) - .ToPageListAsync(page.Page, page.PageSize, totalCount); + .ToPageListAsync(page.PageNum, page.PageSize, totalCount); return new IPage(totalCount, page, pageList); } @@ -725,7 +731,7 @@ public abstract class BaseRepository where T : class, new() .ToList(); } /// - /// + /// /// /// /// @@ -779,7 +785,7 @@ public abstract class BaseRepository where T : class, new() .Insertable(entity) .ExecuteReturnEntity(); } - + /// /// 写入或者更新实体数据 /// @@ -1704,4 +1710,4 @@ public abstract class BaseRepository where T : class, new() -} \ No newline at end of file +}