public async Task <IResultModel> Query(PostQueryModel model) { var result = new QueryResultModel <PostEntity> { Rows = await _repository.Query(model), Total = model.TotalCount }; return(ResultModel.Success(result)); }
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); }
public Task <IResultModel> Query([FromQuery] PostQueryModel model) { return(_service.Query(model)); }