update 扩展dapper分页
This commit is contained in:
@@ -14,16 +14,20 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Dapper;
|
||||||
|
using Ewide.Core.Extension;
|
||||||
|
|
||||||
namespace Ewide.Application.Service.HouseCode
|
namespace Ewide.Application.Service.HouseCode
|
||||||
{
|
{
|
||||||
public class HouseCodeService : IHouseCodeService, IDynamicApiController, ITransient
|
public class HouseCodeService : IHouseCodeService, IDynamicApiController, ITransient
|
||||||
{
|
{
|
||||||
private readonly IRepository<BsHouseCode> _houseCodeRep;
|
private readonly IRepository<BsHouseCode> _houseCodeRep;
|
||||||
|
private readonly IDapperRepository _dapperRepository;
|
||||||
|
|
||||||
public HouseCodeService(IRepository<BsHouseCode> HouseCodeRep)
|
public HouseCodeService(IRepository<BsHouseCode> HouseCodeRep, IDapperRepository dapperRepository)
|
||||||
{
|
{
|
||||||
_houseCodeRep = HouseCodeRep;
|
_houseCodeRep = HouseCodeRep;
|
||||||
|
_dapperRepository = dapperRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("/houseCode/add")]
|
[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 })
|
// .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))
|
// .Where(!string.IsNullOrEmpty(input.HouseCode), cpa => cpa.cp.c.HouseCode.Contains(input.HouseCode))
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
public async Task<dynamic> QueryPage()
|
||||||
|
{
|
||||||
|
var sql = "SELECT * FROM bs_house_code";
|
||||||
|
return await _dapperRepository.QueryPageData(sql, new PageInputBase());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Linq.Expressions;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Dapper;
|
||||||
using Furion.DatabaseAccessor;
|
using Furion.DatabaseAccessor;
|
||||||
using Furion.DatabaseAccessor.Extensions;
|
using Furion.DatabaseAccessor.Extensions;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
@@ -42,5 +43,25 @@ namespace Ewide.Core.Extension
|
|||||||
{
|
{
|
||||||
return source.OrderBy(OrderBuilder<T>(input)).Select(u => u.Adapt<O>()).ToPagedListAsync(input.PageNo, input.PageSize);
|
return source.OrderBy(OrderBuilder<T>(input)).Select(u => u.Adapt<O>()).ToPagedListAsync(input.PageNo, input.PageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Task<IEnumerable<dynamic>> 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<IEnumerable<T>> QueryPageData<T>(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<T>(sql,
|
||||||
|
param: param,
|
||||||
|
transaction: transaction,
|
||||||
|
commandTimeout: commandTimeout,
|
||||||
|
commandType: commandType
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user