示例#1
0
        //***********************SEARCH*************************************
        public virtual ResponseModel <TVm> GeneralSearch(PagingDataType status, BaseRequestModel <TEntity> requestModel)
        {
            int count;
            ResponseModel <TVm> response;

            switch (status)
            {
            case PagingDataType.All:
                count          = Repository.GetAll().Where(requestModel.GetExpression()).Count();
                response       = GetAll(requestModel);
                response.Count = count;
                return(response);

            case PagingDataType.Active:
                count          = Repository.GetAllActive().Where(requestModel.GetExpression()).Count();
                response       = GetAllActive(requestModel);
                response.Count = count;
                return(response);

            case PagingDataType.Inactive:
                count          = Repository.GetAllInactive().Where(requestModel.GetExpression()).Count();
                response       = GetAllInactive(requestModel);
                response.Count = count;
                return(response);

            default:
                throw new ArgumentOutOfRangeException(nameof(status), status, null);
            }
        }
示例#2
0
        public IQueryable <T> SearchQueryable(BaseRequestModel <T> request)
        {
            IQueryable <T> queryable = repository.Get();
            Expression <Func <T, bool> > expression = request.GetExpression();

            queryable = queryable.Where(expression);
            queryable = request.OrderByFunc()(queryable);
            queryable = request.SkipAndTake(queryable);
            queryable = request.IncludeParents(queryable);
            return(queryable);
        }
示例#3
0
 public static IQueryable <TEntity> GetQuery(IQueryable <TEntity> queryable, BaseRequestModel <TEntity> requestModel)
 {
     return(requestModel.GetSkipAndTakeQuery(requestModel.GetOrderedDataQuery(queryable.Where(requestModel.GetExpression()))));
 }