public async Task <IList <MenuEntity> > Query(MenuQueryModel model) { var paging = model.Paging(); var query = Db.Find(); query.WhereNotNull(model.Name, m => m.Name.Contains(model.Name)); query.WhereNotNull(model.RouteName, m => m.RouteName.Contains(model.RouteName)); if (model.ParentId == null) { model.ParentId = Guid.Empty; } query.Where(m => m.ParentId == model.ParentId); var joinQuery = query.LeftJoin <AccountEntity>((x, y) => x.CreatedBy == y.Id); if (!paging.OrderBy.Any()) { joinQuery.OrderBy((x, y) => x.Sort); } joinQuery.Select((x, y) => new { x, CreatorName = y.Name }); var list = await joinQuery.PaginationAsync(paging); model.TotalCount = paging.TotalCount; return(list); }
public async Task <IResultModel> Query(MenuQueryModel model) { var queryResult = new QueryResultModel <Menu>(); var paging = model.Paging(); queryResult.Rows = await _menuRepository.Query(paging, model.Name, model.RouteName, model.ParentId); queryResult.Total = paging.TotalCount; return(ResultModel.Success(queryResult)); }