From 16b3688edbbafe6c875a5af0e8e975b656ac92ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=87=AA=E5=B8=A6=E5=A4=A7=E4=BD=AC=E6=B0=94=E5=9C=BA?= <188633308@qq.com> Date: Thu, 20 May 2021 11:19:08 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=89=A9=E5=B1=95dapper=E5=88=86?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/HouseCode/HouseCodeService.cs | 12 ++++++++++- Api/Ewide.Core/Extension/PageExtensions.cs | 21 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs b/Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs index 0d6ba65..142fa0c 100644 --- a/Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs +++ b/Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs @@ -14,16 +14,20 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Dapper; +using Ewide.Core.Extension; namespace Ewide.Application.Service.HouseCode { public class HouseCodeService : IHouseCodeService, IDynamicApiController, ITransient { private readonly IRepository _houseCodeRep; + private readonly IDapperRepository _dapperRepository; - public HouseCodeService(IRepository HouseCodeRep) + public HouseCodeService(IRepository HouseCodeRep, IDapperRepository dapperRepository) { _houseCodeRep = HouseCodeRep; + _dapperRepository = dapperRepository; } [HttpPost("/houseCode/add")] @@ -62,5 +66,11 @@ namespace Ewide.Application.Service.HouseCode // .Join(areaCodeRep.DetachedEntities, cp => cp.p.AreaCode, a => a.Code, (cp, a) => new { cp, a }) // .Where(!string.IsNullOrEmpty(input.HouseCode), cpa => cpa.cp.c.HouseCode.Contains(input.HouseCode)) //} + + public async Task QueryPage() + { + var sql = "SELECT * FROM bs_house_code"; + return await _dapperRepository.QueryPageData(sql, new PageInputBase()); + } } } diff --git a/Api/Ewide.Core/Extension/PageExtensions.cs b/Api/Ewide.Core/Extension/PageExtensions.cs index c71b777..f10172d 100644 --- a/Api/Ewide.Core/Extension/PageExtensions.cs +++ b/Api/Ewide.Core/Extension/PageExtensions.cs @@ -6,6 +6,7 @@ using System.Linq.Expressions; using System.Reflection; using System.Text; using System.Threading.Tasks; +using Dapper; using Furion.DatabaseAccessor; using Furion.DatabaseAccessor.Extensions; using Mapster; @@ -42,5 +43,25 @@ namespace Ewide.Core.Extension { return source.OrderBy(OrderBuilder(input)).Select(u => u.Adapt()).ToPagedListAsync(input.PageNo, input.PageSize); } + + public static Task> QueryPageData(this IDapperRepository source, string sql, PageInputBase input, object param = null, System.Data.IDbTransaction transaction = null, int? commandTimeout = null, System.Data.CommandType? commandType = null) + { + return source.QueryAsync(sql, + param: param, + transaction: transaction, + commandTimeout: commandTimeout, + commandType: commandType + ); + } + + public static Task> QueryPageData(this IDapperRepository source, string sql, PageInputBase input, object param = null, System.Data.IDbTransaction transaction = null, int? commandTimeout = null, System.Data.CommandType? commandType = null) + { + return source.QueryAsync(sql, + param: param, + transaction: transaction, + commandTimeout: commandTimeout, + commandType: commandType + ); + } } }