コード例 #1
0
        public async Task <IResultModel> Query(PostQueryModel model)
        {
            var result = new QueryResultModel <PostEntity>
            {
                Rows  = await _repository.Query(model),
                Total = model.TotalCount
            };

            return(ResultModel.Success(result));
        }
コード例 #2
0
        public async Task <IList <PostEntity> > Query(PostQueryModel model)
        {
            var paging = model.Paging();

            var query = Db.Find();

            query.WhereNotNull(model.Name, m => m.Name.Contains(model.Name) || m.ShortName.Contains(model.Name));

            var joinQuery = query.LeftJoin <PositionEntity>((x, y) => x.PositionId == y.Id).LeftJoin <AccountEntity>((x, y, z) => x.CreatedBy == z.Id);

            if (!paging.OrderBy.Any())
            {
                joinQuery.OrderByDescending((x, y, z) => x.Id);
            }
            joinQuery.Select((x, y, z) => new { x, PositionName = y.Name, Creator = z.Name });

            var result = await joinQuery.PaginationAsync(paging);

            model.TotalCount = paging.TotalCount;

            return(result);
        }
コード例 #3
0
 public Task <IResultModel> Query([FromQuery] PostQueryModel model)
 {
     return(_service.Query(model));
 }