如安在Asp.Net Core中集成ABP Dapper(2)

  这段代码主要是通过详细传入的参数打算年、打算周、省份......等参数到数据库中查询相关的记录,这里我们先看看基类DcsDapperRepositoryBase<VehicleOrderPlan>内里做了些什么?

public class DcsDapperRepositoryBase<TEntity> : DapperEfRepositoryBase<DcsDbContext, TEntity>         where TEntity : class, IEntity<int> {         public DcsDapperRepositoryBase(IActiveTransactionProvider activeTransactionProvider) : base(activeTransactionProvider) {         }           /// <summary>         /// 以分页的形式查询数据         /// </summary>         /// <typeparam></typeparam>         /// <param></param>         /// <param></param>         /// <param>参数的匿名工具</param>         /// <returns></returns>         protected IEnumerable<TValueObject> QueryPaged<TValueObject>(string sql, PageRequest pageRequest, object parameters = null)             where TValueObject : ValueObjectBase {             var orderCondition = (string.IsNullOrWhiteSpace(pageRequest.Ordering) ? string.Empty : "ORDER BY " + pageRequest.Ordering);             orderCondition.SqlInjectionInspect();             var pagedSql = $@"WITH ""_data"" AS ({sql}),      ""_count"" AS (SELECT COUNT(0) AS OverallCount FROM ""_data"") SELECT * FROM (SELECT A.*, ROWNUM AS ""RowNum""       FROM (SELECT * FROM ""_data""             {orderCondition}) A       WHERE ROWNUM <= {pageRequest.PageSize * (pageRequest.PageIndex + 1)}) B,      ""_count"" WHERE ""RowNum"" > {pageRequest.PageSize * pageRequest.PageIndex}";             return Query<TValueObject>(pagedSql, parameters);         }     }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsjfyz.html